Order when concat streams with event-stream in Gul

2019-06-27 10:15发布

问题:

In this Gulp task, the vendorFiles code is placed after the appFiles code in the dest style.css file.

Is that because the appFiles stream runs faster? How to have the vendorFiles code come before as expected?

gulp.task('styles', function () {

    var vendorFiles = gulp.src(mainBowerFiles()) // don't read
        .pipe(gulpFilter('*.css'));

    var appFiles = gulp.src('app/sass/*.scss')
        .pipe(sass())
        .pipe(prefix('> 5%'));

    return es.concat(vendorFiles, appFiles)
        .pipe(minifyCSS())
        .pipe(concat('style.css'))
        .pipe(gulp.dest('./dist/css'));
});

回答1:

solved it with gulp-order

gulp.task('scripts', function () {

    var jsFilter = gulpFilter('*.js');
    var vendorFiles = gulp.src(mainBowerFiles())
        .pipe(jsFilter)
        .pipe(concat('vendor.js'));

    var appFiles = gulp.src('app/js/*.js')
        .pipe(jshint())
        .pipe(jshint.reporter('default'))
        .pipe(concat('app.js'));

    return eventStream.concat(vendorFiles, appFiles)
        .pipe(order([
            "vendor.js",
            "app.js"
        ]))
        .pipe(concat('app.js'))
        .pipe(uglify())
        .pipe(gulp.dest('./dist/js'));
});


标签: stream gulp