更新时间:2023-02-16 19:28:19
我能够使用合并流解决这个问题.如果有人有兴趣,这里是代码.这个想法是在循环中创建一个流数组,并在完成迭代时合并它们:
I was able to pull this off using merge-streams. If anyone's interested, here's the code. The idea is to create an array of streams inside your loop and merge them when finished iterating:
var merge = require('merge-stream');
gulp.task('js', function(){
// Init vars
var jsBundleStreams = [];
var i = 0;
// Create array of individual bundle streams
for (var key in buildConfig.bundle) {
jsBundleStreams[i] = gulp.src(bundleConfig.bundle[key].scripts)
.pipe(concat(key + '.js'))
.pipe(gulp.dest('./public/papasteftest/'));
i++;
}
// Merge and return streams
return merge.apply(this, jsBundleStreams);
});