How to run Gulp tasks sequentially one after the other

前端 未结 14 1013
眼角桃花
眼角桃花 2020-11-22 13:00

in the snippet like this:

gulp.task \"coffee\", ->
    gulp.src(\"src/server/**/*.coffee\")
        .pipe(coffee {bare: true}).on(\"error\",gutil.log)
           


        
14条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 13:19

    The only good solution to this problem can be found in the gulp documentation:

    var gulp = require('gulp');
    
    // takes in a callback so the engine knows when it'll be done
    gulp.task('one', function(cb) {
      // do stuff -- async or otherwise
      cb(err); // if err is not null and not undefined, the orchestration will stop, and 'two' will not run
    });
    
    // identifies a dependent task must be complete before this one begins
    gulp.task('two', ['one'], function() {
      // task 'one' is done now
    });
    
    gulp.task('default', ['one', 'two']);
    // alternatively: gulp.task('default', ['two']);
    

提交回复
热议问题