最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to concatenate two streams using gulp? - Stack Overflow

programmeradmin0浏览0评论

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?

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?

Share Improve this question asked Mar 7, 2016 at 8:48 aciderntacidernt 2,3113 gold badges21 silver badges36 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 8

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

发布评论

评论列表(0)

  1. 暂无评论