grunt-concurrent
isn't necessary, grunt-contrib-watch
can watch multiple directories in the way you've defined it. I gutted your file to try it out and caught two issues
- A hyphen doesn't seem to be allowed in a Grunt task name.
grunt watch
doesn't suspend if the directory is empty. Once there's something in there, it will suspend.
Here's the simplified version:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
watch: {
'JSFiles': {
files: [ 'raw_assets/javascript/*.js' ],
tasks: ['closure_compiler'],
options: {
spawn: true,
},
}, //End of Watch call for JS Files
'ScssFiles': {
files: ['raw_assets/sass/*.scss'],
tasks: ['sass'],
options: {
spawn: true,
},
} //End of Watch SCSS Files
} //End of Watch
});
// Load the plugins
grunt.loadNpmTasks('grunt-contrib-watch');
//When 'Grunt' is run perform watch function
grunt.registerTask('closure_compiler', function() {
grunt.log.writeln("in closure_compiler");
});
grunt.registerTask('sass', function() {
grunt.log.writeln("in sass");
});
}; //End of GruntFile
I then ran npm install grunt grunt-cli grunt-contrib-watch
, and created the raw_assets
directory with javascript
and sass
subdirectories. I then created a single empty JS file and SCSS file, and ran grunt watch
.
Any modifications in either of the two subdirectories run the correct task.
$ grunt watch
Running "watch" task
Waiting...OK
>> File "raw_assets/sass/foo2.scss" added.
Running "sass" task
in sass
Done, without errors.
Completed in 0.381s at Mon Mar 03 2014 00:21:46 GMT+0100 (CET) - Waiting...
OK
>> File "raw_assets/javascript/new.js" added.
Running "closure_compiler" task
in closure_compiler
Done, without errors.
Completed in 0.381s at Mon Mar 03 2014 00:27:50 GMT+0100 (CET) - Waiting...