如何使用gulp连接两个流?

时间:2016-03-07 08:48:01

标签: javascript gulp concatenation

例如,我有一个包含下一个内容的任务:

<script type="text/javascript"> 
$(function () {
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        title: {
            text: ''
        },
        subtitle: {
            text: ''
        },
        xAxis: {
            categories: [
                '1000',
                '2000',
                '3000',
                '4000',
                '5000',
                '6000',
                '7000',
                '8000',
                '9000',
                '10000',
                '11000',
                '12000'
            ],
            crosshair: true

        },
        yAxis: {
            min:0 ,
            title: {
                text: null
            }
        },
        tooltip: {
            headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
            pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
                '<td style="padding:0"><b>{point.y} mm</b></td></tr>',
            footerFormat: '</table>',
            shared: true,
            useHTML: true
        },
        legend: {
                    layout: 'vertical',
                    align: 'center',
                    verticalAlign: 'top',

                    floating: true,
                    borderWidth: 1,
                    width: 100,
                    height: 100
                },
        plotOptions: {
           series: {
                borderWidth: 0,
                dataLabels: {
                    enabled: true,
                    format: '{point.y}'
                }
            }
        },
        labels:
        {
          enabled: false
        },
        series: [{
            name: 'Tokyo',
            data: [<?php echo $dest_pcode; ?>, 121, 111, 154, 143, 143, 165, 148, 216, 194, 95,142]

        },{
            name: 'Berlin',
            data: [<?php echo $origin_pcode; ?>, 33, 176, 39, 52, 75, 133, 47, 177, 46, 51,110]
            }]
    });
});
</script>

如果我不想将这些文件放在文件系统中的任何位置怎么办?我可以以某种方式在任务中连接function task() { gulp.src('libs/*.js') // some manipulations .concat('libs.js') gulp.src('js/*.js') // Another manipulations .concat('app.js') } libs.js吗?

1 个答案:

答案 0 :(得分:3)

您可以使用merge-stream包。简单的例子:

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 我希望它会对你有帮助。

由于