gruntjs - grunt-contrib-watch slow even with spawn = false -
i have set grunt-contrib-watch task copy list of files "dist" directory every time save 1 of files of "src" directory. unfortunately takes 7 9 seconds accomplish task.
i have heard "spawn" option grunt-contrib-watch. using load-grunt-tasks load config of each task separate json file, changed watch.json looks :
{ "service": { "files": [ "src/*.php" ], "tasks": [ "copy:service" ], "options": { "spawn": "false", "livereload": "true" } } }
...but setting false doesn't seems change : still takes 7 9 seconds run. installed time-grunt monitor task timing, here got when saving file :
when saving file, got following output :
waiting... >> file "src\myfile.php" changed. running "copy:service" (copy) task created 7 directories, copied 120 files done, without errors. execution time (2015-06-04 11:38:23 utc) loading tasks 333ms ██████████████████ 40% copy:service 490ms ██████████████████████████ 60% total 823ms completed in 7.105s @ thu jun 04 2015 13:38:24 gmt+0200 (w. europe daylight time)
so looks task in took less second, meaning grunt take 6 seconds load ? seems pretty high. i'm on windows 7, i've heard on windows there performance issues.
same problem here, after changed , execute task modules reload.
but found solution on github (https://github.com/steida/grunt-este-watch)
what's wrong official grunt-contrib-watch?
it's slow , buggy, because uses combination fs.filewatch , fs.watch, historical reason. node 0.9.2+, fs.watch ok.
what do?
install grunt-este-watch
npm install grunt-este-watch --save-dev
change contrib watch
grunt.loadnpmtasks('grunt-contrib-watch');
to este watch
grunt.loadnpmtasks('grunt-este-watch');
change task
watch: { javascript: { files: 'src/js/**/*', tasks: ['uglify'] } }
to
estewatch: { options: { dirs: ['../src/**/*'] }, 'js': function(filepath) { return 'uglify' } }
Comments
Post a Comment