Gulp: Synchronicity without dependency

给你一囗甜甜゛ 提交于 2019-12-14 03:48:13

问题


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.


回答1:


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!



来源:https://stackoverflow.com/questions/24342030/gulp-synchronicity-without-dependency

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!