Gulp:无依赖性的同步性 [英] Gulp: Synchronicity without dependency

查看:118
本文介绍了Gulp:无依赖性的同步性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经定义了各种构建任务( 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆