MDL-49817 grunt: add watch task

This allows files to be watched and automatically build when changed.

Thanks to David Monllaó for the initial basis for this patch.
This commit is contained in:
Dan Poltawski 2016-01-14 13:22:28 +00:00
parent 5cc5f31101
commit 8efbb7b1a1
3 changed files with 1462 additions and 2175 deletions

View File

@ -74,6 +74,23 @@ module.exports = function(grunt) {
compress: true
}
}
},
watch: {
options: {
nospawn: true // We need not to spawn so config can be changed dynamically.
},
amd: {
files: ['**/amd/src/**/*.js'],
tasks: ['amd']
},
bootstrapbase: {
files: ["theme/bootstrapbase/less/**/*.less"],
tasks: ["less:bootstrapbase"]
},
yui: {
files: ['**/yui/src/**/*.js'],
tasks: ['shifter']
},
}
});
@ -245,10 +262,17 @@ module.exports = function(grunt) {
};
// On watch, we dynamically modify config to build only affected files.
grunt.event.on('watch', function(action, filepath) {
grunt.config('jshint.amd.src', filepath);
grunt.config('uglify.amd.files', [{ expand: true, src: filepath, rename: uglify_rename }]);
});
// Register NPM tasks.
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
// Register JS tasks.
grunt.registerTask('shifter', 'Run Shifter against the current directory', tasks.shifter);

3612
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,7 @@
"grunt-contrib-jshint": "0.11.3",
"grunt-contrib-less": "1.1.0",
"grunt-contrib-uglify": "0.11.0",
"grunt-contrib-watch": "0.6.1",
"shifter": "0.5.0"
}
}