How to run Gulp tasks sequentially one after the other

前端 未结 14 946
眼角桃花
眼角桃花 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:25

    I was searching for this answer for a while. Now I got it in the official gulp documentation.

    If you want to perform a gulp task when the last one is complete, you have to return a stream:

    gulp.task('wiredep', ['dev-jade'], function () {
        var stream = gulp.src(paths.output + '*.html')
            .pipe($.wiredep())
            .pipe(gulp.dest(paths.output));
    
        return stream; // execute next task when this is completed
    });
    
    // First will execute and complete wiredep task
    gulp.task('prod-jade', ['wiredep'], function() {
        gulp.src(paths.output + '**/*.html')
            .pipe($.minifyHtml())
            .pipe(gulp.dest(paths.output));
    });

提交回复
热议问题