跳过任务列为饮料中的依赖项 [英] Skipping Tasks Listed as Dependencies in Gulp
问题描述
我已经浏览了所有的文档和NPM,试图找到解决办法,但我没有运气。我希望可以选择跳过在运行特定任务时列为依赖关系的任务。例如,如果我有以下内容:
I have looked all over the documentation and NPM to try to find a solution to this, but I have had no luck. I would like to have the option to skip the tasks that I list as dependencies when running a specific task. For example, if I have the following:
gulp.task('prerun', function(){
// do cleaning, installation, etc.
});
gulp.task('run', ['prerun'], function(){
// do stuff
});
gulp.task('watch', function(){
gulp.watch('glob/glob/**', ['run']);
});
我希望能够让我的 gulp.watch
执行运行
,而无需触及 prerun
中涉及的开销。这是所有可能的Gulp?
I would like to be able to have my gulp.watch
execute run
without having to touch the overhead involved in prerun
. Is this at all possible in Gulp?
推荐答案
关于助手任务是什么?我使用这种方法来消除我的监视任务中的任何依赖关系。你的例子可以看起来像这样:
What's about a helper task? I use this approach to eliminate any dependencies in my watch tasks. Your example can look like this:
gulp.task('prerun', function(){
// do cleaning, installation, etc.
});
gulp.task('run', ['prerun'], function(){
gulp.start('run-dev');
});
gulp.task('run-dev', function() {
// do the run stuff
});
gulp.task('watch', function(){
gulp.watch('glob/glob/**', ['run-dev']);
});
如果需要,还可以将预运行任务用作监视任务的依赖项:
The prerun task you can also use as dependency for your watch task if needed:
gulp.task('watch', ['prerun'], function(){
gulp.watch('glob/glob/**', ['run-dev']);
});
Ralf
Ciao Ralf
这篇关于跳过任务列为饮料中的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!