当Gulp Watch只需要处理已修改的文件时,我就会遇到问题
当我开始时,Gulp会正确执行任务,但是当我进行更改时,Gulp watch会再次执行所有任务,而不仅仅是已更改的任务。我不知道这可能是什么问题,您能帮我吗?
// Watch Task: watch SCSS and JS files for changes
// If any change, run scss and js tasks simultaneously
function watchTask() {
watch([files.htmlPath, files.scssPath, files.mincssPath, files.cssPath, files.minjsPath, files.jsPath, files.imgPath],
parallel(htmlTask, siteTask, series(scssTask, cleanTask, concatCSS), series(jsminTask, jsTask), imgTask));
}
// Export the default Gulp task so it can be run
// Runs the scss and js tasks simultaneously
// then runs cacheBust, then watch task
exports.default = series(
parallel(htmlTask, siteTask, series(scssTask, cleanTask, concatCSS), series(jsminTask, jsTask), imgTask),
cacheBustTask,
watchTask
);
答案 0 :(得分:1)
要实现您的目标,您应该创建单独的监视功能并并行运行它们。
类似的东西
exports.watch = gulp.parallel(watch_html, watch_scss,...);
function watch_html() {
return gulp.watch(files.htmlPath, htmlTask);
}
function watch_scss(){
return gulp.watch(files.scssPath, series(scssTask, cleanTask, concatCSS));
}