Gulp.js, watch task runs twice when saving files

后端 未结 12 1217
花落未央
花落未央 2020-12-15 11:03

Given the following piece of code from my gulpfile.js, everytime I save or change a file, the task runs twice instead of one single time, why is that? I just want it to run

12条回答
  •  死守一世寂寞
    2020-12-15 11:59

    Hint: the debounce parameter only works for the SAME file/event. If multiple events/files change, it won't help. Sometimes (e.g. I copied files into the a directory being served by my local server) gulp-cached might help, sometimes excluding certain files/patterns (e.g. the sourcemaps files) might help (use ! to negate the selection). e.g.

    gulp.watch(['js/**/*', '!js/**/*.map'])
    

提交回复
热议问题