By default, gulp runs tasks simultaneously, unless they have explicit dependencies.
(默认情况下,gulp同时运行任务,除非它们具有显式依赖关系。)
This isn't very useful for tasks like clean
, where you don't want to depend, but you need them to run before everything else.(这对于像clean
这样的任务来说并不是很有用,你不想依赖它,但是你需要它们才能在其他任何事情之前运行。)
I wrote the run-sequence
plugin specifically to fix this issue with gulp.
(我写了一个run-sequence
插件,专门用gulp解决了这个问题。)
After you install it, use it like this:(安装后,使用它如下:)
var runSequence = require('run-sequence');
gulp.task('develop', function(done) {
runSequence('clean', 'coffee', function() {
console.log('Run something else');
done();
});
});
You can read the full instructions on the package README — it also supports running some sets of tasks simultaneously.
(您可以阅读自述文件包README上的完整说明 - 它还支持同时运行一些任务集。)
Please note, this will be (effectively) fixed in the next major release of gulp , as they are completely eliminating the automatic dependency ordering, and providing tools similar to run-sequence
to allow you to manually specify run order how you want.
(请注意,这将在gulp的下一个主要版本中(有效)修复 ,因为它们完全消除了自动依赖性排序,并提供类似于run-sequence
工具,允许您手动指定运行顺序的方式。)
However, that is a major breaking change, so there's no reason to wait when you can use run-sequence
today.
(但是,这是一个重大的突破性变化,因此没有理由等待今天可以使用run-sequence
。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…