From 9ee0ee5e940a5e3fd09b49b0883cdf1ddc8590c8 Mon Sep 17 00:00:00 2001 From: Remi Marenco Date: Fri, 29 Apr 2016 12:47:15 -0400 Subject: [PATCH] Add grunt watcher on the .less files --- client/grunt-tasks/style.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/client/grunt-tasks/style.js b/client/grunt-tasks/style.js index 190d2722f89..99a7d592d98 100644 --- a/client/grunt-tasks/style.js +++ b/client/grunt-tasks/style.js @@ -75,15 +75,30 @@ module.exports = function( grunt ){ ] }); + + // -------------------------------------------------------------------------- watch & rebuild less files + // use 'grunt watch-style' (from a new tab in your terminal) to have grunt re-copy changed files automatically + grunt.config( 'watch', { + watch: { + // watch for changes in the src dir + files: [ lessPath + '/**' ], + tasks: ['check-modules', 'sprite', 'less-site-config', 'less', 'clean'], + options: { + spawn: false + } + } + }); + grunt.loadNpmTasks( 'grunt-contrib-less' ); grunt.loadNpmTasks( 'grunt-spritesmith' ); grunt.loadNpmTasks( 'grunt-contrib-clean' ); - + grunt.loadNpmTasks( 'grunt-contrib-watch' ); // Write theme variable for less grunt.registerTask( 'less-site-config', 'Write site configuration for less', function() { grunt.file.write( fmt( '%s/tmp-site-config.less', lessPath ), fmt( "@theme-name: %s;", theme ) ); }); + grunt.registerTask( 'watch-style', [ 'watch' ] ); grunt.registerTask( 'style', [ 'check-modules', 'sprite', 'less-site-config', 'less', 'clean' ] ); };