使用简单的构建结构如下(其中{...}
代表不相关的回调):
gulp.task('clean', {...}); //task I want to run once before the first build
gulp.task('build', ['clean'], {...}); //task I want to run at each change
gulp.task('watch, ['build'], function() {
gulp.watch('./', ['build']);
});
gulp.task('default', ['watch']);
每次观看'被触发,清洁'任务在“构建”之前运行。任务...我想避免重新运行' clean'每一次。
我尝试了一段时间来找到一个依赖关系结构,允许这个或我错过的工具,但我没有找到任何看起来过于复杂的解决方案。
处理这个问题的最佳方法是什么?
答案 0 :(得分:1)
使用2个不同的任务。
gulp.task('build-with-clean', ['clean'], {...});
gulp.task('build-to-watch', {...});
gulp.task('watch', ['build-to-watch'], function() {
gulp.watch('./', ['build-to-watch']);
});