简体   繁体   English

gulp-watch插件不会在新文件上触发

[英]gulp-watch plugin doesn't trigger on new files

I read that watch function delivered with gulp package doesn't trigger on new files (and indeed it didn't). 我读到gulp软件包附带的监视功能不会在新文件上触发(实际上不会触发)。 But then I read somewhere that it should work fine with gulp-watch plugin. 但是后来我读到某个地方,它可以与gulp-watch插件配合使用。 So I did install it and set up my gulpfile but still the same thing, it dosen't run tasks whenever I put new files. 因此,我确实安装了它并设置了gulpfile但是还是一样,无论何时放置新文件,它都不会运行任务。

(gruntfile.js) (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();
  });
});

Is that even possible to make it happen, to gulp-watch plugin watch for new files? gulp-watch插件监视新文件是否有可能实现?

Ive been using Gulp for a couple of year now and never found an issue to this. 我已经使用Gulp两年了,但从未发现有问题。 When you run Gulp, during its compilation it takes note of the existing files and watches them only. 当您运行Gulp时,在编译过程中,它会记录现有文件并仅监视它们。 A newly added file is not in Gulps memory, therefore it struggles to 'watch' new files... Being able to watch a folder would be a better choice. 新添加的文件不在Gulps内存中,因此很难“监视”新文件...能够监视文件夹是一个更好的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM