【发布时间】:2015-09-11 00:43:43
【问题描述】:
我有一个 gulp 任务,它执行一些非常常见的任务 - 它运行 jshint 来验证我的代码,然后连接并最小化文件并将它们输出到单个 .min.js 文件中。
当我手动运行任务时(似乎)可以完美执行。但是第二次我尝试在 $gulp.watch 中使用它时,它不再输出我的文件(尽管它仍然执行并执行 jshint)。
我的任务中的代码:
gulp.src(path.join(workingPath, folder, '/*.js'))
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail')) //stop build if errors found
.on('error', function() {
console.log("Please review and correct jshint errors.");
this.end();
})
.pipe(order([ //order files before concat - ensure module definitions are first
"*.module.js",
"*.js"
]))
.pipe(concat(filename+'.js'))
.pipe(gulp.dest(destinationPath)) //full combined version
.pipe(uglify())
.pipe(rename(filename+'.min.js'))
.pipe(gulp.dest(destinationPath)) //minified combined version
.on('error',function() {
console.log("An error occurred during Gulp processing.");
this.end();
});
我的 gulp 手表(任务名为“组件”):
gulp.watch(componentsBasePath+"/**/*.js",['components']);
我注意到的一件事是在手动运行结束时,我看到“进程完成,退出代码......”。如果我杀死我的 gulp.watch,它会输出“进程完成,退出代码......” - 然后它会创建输出文件!
我的目标是让我的“组件”任务在每次被手表触发时创建这些输出文件 - 而不仅仅是在我杀死手表时。
谢谢!
悬崖
【问题讨论】:
标签: gulp gulp-watch