node.js - Grunt Watch LESS files in folder and create css when less file is changed -
i looking grunt automation task watches less files in root directory , gives css files of same name less files in same directory like
root folder package.json gruntfile.js folder1 file1.less file2.less folder2 file3.less file4.less
my gruntfile.js
module.exports = function(grunt) { grunt.initconfig({ //our less options less: { development: { files: { "": "" //not able write line, how can mention file compile watching entire folder } } }, watch: { css: { files: '**/*.less', tasks: ['less'] } } }); //load our tasks grunt.loadnpmtasks('grunt-contrib-less'); grunt.loadnpmtasks('grunt-contrib-watch'); //default tasks run grunt.registertask('default', ['less']); }
not able mention source less file name , result css file name in less task config, watching entire folder, want create css file corresponding less file in same path less, whenever particular css changed. want compile less file changed , not less files compiled, if 1 less changed.
thanks in advance help.
you can use grunt-newer configure less task run newer files only.
npm install grunt-newer --save-dev
once plugin installed, add
grunt.loadnpmtasks('grunt-newer');
edit watch task:
watch: { css: { files: '**/*.less', tasks: ['newer:less'] } }
Comments
Post a Comment