简体   繁体   中英

How to concatenate two streams using gulp?

For example I have a task with next content:

function task() {
    gulp.src('libs/*.js')
        // some manipulations
        .concat('libs.js')

    gulp.src('js/*.js')
        // Another manipulations
        .concat('app.js')
}

What if I don't want to put this files anywhere in file system? Can I somehow concatenate libs.js and app.js inside a task?

You can use merge-stream package. Simple example:

gulp.task("do-something", function() {
    var vendorScripts1 = gulp.src("libs/*.js")
        .pipe(/* I want to do something*/));

    var vendorScripts2 = gulp.src("js/*.js")
        .pipe(/* I want to do something else here*/);

    return merge(vendorScripts1 , vendorScripts2)
      .pipe(/*bla bla bla*/);
});

Github example I hope it will help you.

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM