I have a gulp watch task as following:
gulp.task("watch", () => {
const watch = {
'dev': [src_folder + '**/*.njk', src_js_folder + '**/*.js'],
'css': [src_sass_folder + '**/*.scss']
}
gulp.watch(watch.dev, gulp.series("dev")).on("change", browserSync.reload);
gulp.watch(watch.css, gulp.series("sass"));
});
gulp.task("dev", gulp.series("merge-json", "nunjucks", "sass", "js"));
So when there's any changes on *.sass
files the sass
task will run, and when there's changes on *.js
and/or *.njk
files the task dev
will run.
The problem I'm having is when there are changes on *.sass
, *.js
and/or *.njk
at the same time, the sass
task will run twice in this case.
How can I skip the gulp.watch(watch.css, gulp.series("sass"));
when the gulp.watch(watch.dev, gulp.series("dev")).on("change", browserSync.reload);
is already run.
from Add a condition to run a gulp watch
No comments:
Post a Comment