Can't start the Grunt `watch` task?

Below is my grunt file. My watch:news doesn't work, and I'm not sure why.

When I work in verbose mode, I see that all NPM modules load without problems, and it checks that the watch:news task is started, as it should be, but then it just does not accept any changes have occurred?

I'm sure this is probably a typo or some kind of small / easily fixed problem, I just can’t notice it?

Any help is much appreciated!

 module.exports = function (grunt) { /* Grunt installation: ------------------- npm install -g grunt-cli npm install -g grunt-init npm init (creates a `package.json` file) Project Dependencies: --------------------- npm install grunt --save-dev npm install grunt-contrib-watch --save-dev npm install grunt-contrib-jshint --save-dev npm install grunt-contrib-uglify --save-dev npm install grunt-contrib-requirejs --save-dev npm install grunt-contrib-sass --save-dev npm install grunt-contrib-imagemin --save-dev Example Usage: -------------- grunt -v grunt release -v */ // Project configuration. grunt.initConfig({ // Store your Package file so you can reference its specific data whenever necessary pkg: grunt.file.readJSON('package.json'), dir: { static: './tabloid/webapp/static/', static_js: '<%= dir.static %>' + 'js/', static_sass: '<%= dir.static %>' + 'sass/', static_css: '<%= dir.static %>' + 'stylesheets/', static_img: '<%= dir.static %>' + 'img/' }, jshint: { files: ['<%= dir.static %>**/*.js', '!<%= dir.static_js %>jasmine/lib/**/*.js', '!<%= dir.static_js %>build.js', '!<%= dir.static_js %>compiled/**/*.js', '!<%= dir.static_js %>locator/**/*.js', '!<%= dir.static_js %>msie/**/*.js', '!<%= dir.static_js %>vendor/**/*.js'], options: { curly: true, eqeqeq: true, immed: true, latedef: true, noarg: true, sub: true, undef: true, boss: true, eqnull: true, browser: true, multistr: true, newcap: false, globals: { // AMD module: true, require: true, requirejs: true, define: true, // Environments console: true, // General Purpose Libraries $: true, jQuery: true, EventEmitter: true, // Testing sinon: true, describe: true, it: true, expect: true, beforeEach: true, afterEach: true } } }, requirejs: { compile: { options: { baseUrl: '<%= dir.static_js %>', paths: { 'jquery-1': 'vendor/jquery-1/jquery.min', 'jquery': 'vendor/jquery-2/jquery.min', 'domReady': 'vendor/require/domReady', 'translation': 'module/translations/news' }, exclude: ['config', 'jquery' ], name: 'define', out: '<%= dir.static_js %>compiled/all.js', fileExclusionRegExp: /^\.|node_modules|Gruntfile|\.md|package.json/ } } }, sass: { dist: { options: { style: 'compressed', require: ['<%= dir.static_sass %>helpers/url64.rb'] }, expand: true, cwd: '<%= dir.static_sass %>', src: ['*.scss', '!_*.scss'], dest: '<%= dir.static_css %>', ext: '.css' }, dev: { options: { style: 'expanded', debugInfo: true, lineNumbers: true, require: ['<%= dir.static_sass %>helpers/url64.rb'] }, expand: true, cwd: '<%= dir.static_sass %>', src: ['*.scss', '!_*.scss'], dest: '<%= dir.static_css %>', ext: '.css' }, news: { options: { style: 'expanded', debugInfo: true, lineNumbers: true, require: ['<%= dir.static_sass %>helpers/url64.rb'] }, expand: true, cwd: '<%= dir.static_sass %>/services/news/', src: ['*.scss'], dest: '<%= dir.static_css %>/services/news/', ext: '.css' } }, // `optimizationLevel` is only applied to PNG files (not JPG) imagemin: { png: { options: { optimizationLevel: 7 }, files: [ { expand: true, cwd: '<%= dir.static %>img/', src: ['**/*.png'], dest: '<%= dir.static %>img/', ext: '.png' } ] }, jpg: { options: { progressive: true }, files: [ { expand: true, cwd: '<%= dir.static %>img/', src: ['**/*.jpg'], dest: '<%= dir.static %>img/', ext: '.jpg' } ] } }, // Run: `grunt watch -v` from command line for this section to take effect // The -v flag is for 'verbose' mode, this means you can see the Sass files being compiled along with other important information watch: { all: { files: ['<%= jshint.files %>', '<%= sass.dev.src %>'], tasks: ['default'] }, news: { files: ['<%= sass.news.src %>'], tasks: ['news'] } } }); // Load NPM Tasks grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-requirejs'); grunt.loadNpmTasks('grunt-contrib-sass'); grunt.loadNpmTasks('grunt-contrib-imagemin'); // Default Task grunt.registerTask('default', ['jshint', 'sass:dev']); // News Task grunt.registerTask('news', ['sass:news']); // Release Task grunt.registerTask('release', ['jshint', 'requirejs', 'sass:dist', 'imagemin']); }; 
+4
source share
1 answer

It <%= sass.news.src %> out that the problem is related to viewing <%= sass.news.src %> , which does not work, since we use the global scaling of the Grunt extended directory.

The solution was to link directly to the folder I wanted to see: <%= dir.static_sass %>**/*.scss'

+2
source

Source: https://habr.com/ru/post/1483537/


All Articles