Gulp:无依赖性的同步性 [英] Gulp: Synchronicity without dependency
问题描述
我已经定义了各种构建任务( scripts
, style ,
jade
等)以及清理
任务,删除所有构建的文件。
我想确保构建任务在清理任务之前不运行, 但是我也希望能够在不清理的情况下运行构建任务。
即我想:
gulp.task('build',['clean','scripts','style','jade']) ;
要开始运行脚本
, style
和 jade
之后 clean
已完成,但
gulp.task('watch',function(){
gulp.watch('path / to / stylus',['css' ]);
});
不应触发 clean
如果 css
依赖于 clean
。
...
var sequence = require('run-sequence');
gulp.task('dev',['css','js','html']);
gulp.task('watch',function(){
gulp.watch(src.css,['css']);
gulp.watch (src.js,['js']);
gulp.watch(src.html,['html']);
});
gulp.task('default',function(done){
sequence('clean','dev','watch',done);
});
https://www.npmjs.org/package/run-sequence
请阅读:
这是一个临时解决方案,直到orchestrator更新为支持非依赖性的有序任务。
顺便说一句,感谢 https://stackoverflow.com/users/145185/overzealous !
I'm migrating my build system over to gulp, and have encountered a problem:
I have defined various build tasks (scripts
, style
, jade
, etc), as well as a clean
task that removes all of the built files.
I want to make sure that the build tasks don't run before the clean tasks, BUT I also want to be able to run the build tasks without cleaning first.
i.e. I want:
gulp.task('build', ['clean', 'scripts', 'style', 'jade']);
To only start running scripts
, style
and jade
after clean
has finished, but
gulp.task('watch', function(){
gulp.watch('path/to/stylus', ['css']);
});
Should not trigger clean
to be run, which would be the case if css
had a dependency on clean
.
I've faced the same problem:
...
var sequence = require('run-sequence');
gulp.task('dev', ['css', 'js', 'html']);
gulp.task('watch', function() {
gulp.watch(src.css, ['css']);
gulp.watch(src.js, ['js']);
gulp.watch(src.html, ['html']);
});
gulp.task('default', function(done) {
sequence('clean', 'dev', 'watch', done);
});
https://www.npmjs.org/package/run-sequence
Please, read:
This is intended to be a temporary solution until orchestrator is updated to support non-dependent ordered tasks.
BTW, thanks https://stackoverflow.com/users/145185/overzealous!
这篇关于Gulp:无依赖性的同步性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!