1

我读到gulp包提供的监视功能不会在新文件上触发(实际上它没有)。但是后来我在某处读到它应该可以与gulp-watch插件一起正常工作。所以我确实安装了它并设置了我gulpfile但仍然相同的东西,每当我放置新文件时它都不会运行任务。

(gruntfile.js)

function gulpTemplates() {
  return gulp.src(path.templates)
        .pipe(jade())
        .pipe(gulp.dest('./public/templates'));
}

...

gulp.task('watch', function () {
  watch(path.components, gulpBower);
  watch(path.index, gulpJade);
  watch(path.templates, gulpTemplates);
  watch(path.styles, gulpSass);
  watch(path.scripts, function () {
    gulpLint();
    gulpJs();
  });
});

是否有可能实现gulp-watch插件监视新文件?

4

1 回答 1

1

我已经使用 Gulp 几年了,从来没有发现这个问题。当您运行 Gulp 时,它会在编译期间记录现有文件并仅监视它们。新添加的文件不在 Gulps 内存中,因此它很难“观看”新文件......能够观看文件夹将是一个更好的选择。

于 2015-01-21T09:30:57.647 回答