即使没有任何变化,Gulp手表也会不间断地开火

时间:2018-03-02 13:52:08

标签: gulp gulp-watch

就像标题一样,我目前在Gulp手表上遇到了一个令人讨厌的问题,即使没有做出任何改动,它也会继续编译我的文件。

例如,这是我的一块手表'任务

gulp.task('watch', function() {
  gulp.watch(jsIn, ['babel']);
}

而我的' babel'任务,只是为了编译我的脚本并将它们移动到dist文件夹

const jsIn = ['dev/scripts/*.js', 'dev/scripts/**/*.js'],
      jsOut = 'dist/scripts';

gulp.task('babel', function() {
gulp.src(jsIn)
    .pipe(babel())
        .on('error', gutil.log)
    .pipe(gulp.dest(jsOut))
    .pipe(connect.reload()); //yes I use gulp-connect to live reload my files.
});

当我运行gulp watch它正常工作,然后继续发生

TRUONGs-MacBook-Pro:code sdsmnc$ gulp watch
[14:48:31] Using gulpfile /Volumes/SDSMNC_BU/2018/wildlife/code/gulpfile.js
[14:48:31] Starting 'watch'...
[14:48:31] Finished 'watch' after 14 ms
[14:48:32] Starting 'babel'...
[14:48:32] Finished 'babel' after 14 ms
[14:48:34] Starting 'babel'...
[14:48:34] Finished 'babel' after 1.95 ms
[14:48:34] Starting 'babel'...
[14:48:34] Finished 'babel' after 1.5 ms
[14:48:37] Starting 'babel'...
[14:48:37] Finished 'babel' after 1.18 ms
[14:48:39] Starting 'babel'...
[14:48:39] Finished 'babel' after 1.07 ms
[14:48:41] Starting 'babel'...
[14:48:41] Finished 'babel' after 1.03 ms
[14:48:42] Starting 'babel'...
[14:48:42] Finished 'babel' after 1.73 ms
[14:48:44] Starting 'babel'...
[14:48:44] Finished 'babel' after 1.04 ms

我实际上对我的所有项目使用相同的gulpfile.js,旧的工作正常,但在这个新项目中,我得到了这个问题。我尝试删除node_modules文件夹并重新安装所有依赖项,甚至使用旧项目的node_modules但无法解决问题。

请帮忙......?

0 个答案:

没有答案