Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 800
acidernt Avatar asked Mar 07 '16 08:03

acidernt


Video Answer


1 Answers

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

like image 69
The Reason Avatar answered Oct 19 '22 20:10

The Reason