我正在努力让两条并行处理路线在 gulp 中工作。我的代码如下所示:
gulp.task('build', function(){
return gulp.src(src,{cwd:srcDir})
.pipe(concat('sdk.js', {newLine:'\n\n'}))
.pipe(gulp.dest('dist/'))
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(es.merge(
gulp.src('dist/sdk.js')
.pipe(preprocess({context:{debug:true}}))
.pipe(rename('sdk.debug.js')),
gulp.src('dist/sdk.js')
.pipe(preprocess({context:{}}))
.pipe(uglify())
.pipe(rename('sdk.min.js'))
))
//some more processing
.pipe(gulp.dest('dist/'))
;
});
我在这里找到了一个建议,即这种分叉然后合并流的方式应该可行。但是,我收到错误:
stream.js:79
dest.end();
^
TypeError: Object #<Stream> has no method 'end'
at Stream.onend (stream.js:79:10)
at Stream.EventEmitter.emit (events.js:117:20)
at end (C:\Users\user\Documents\proj\node-sdk\node_modules\gulp-
jshint\node_modules\map-stream\index.js:116:39)
at Stream.stream.end (C:\Users\user\Documents\proj\node-sdk\node
_modules\gulp-jshint\node_modules\map-stream\index.js:122:5)
at Stream.onend (stream.js:79:10)
at Stream.EventEmitter.emit (events.js:117:20)
at end (C:\Users\user\Documents\proj\node-sdk\node_modules\gulp-
jshint\node_modules\map-stream\index.js:116:39)
at queueData (C:\Users\user\Documents\proj\node-sdk\node_modules
\gulp-jshint\node_modules\map-stream\index.js:62:17)
at next (C:\Users\user\Documents\proj\node-sdk\node_modules\gulp
-jshint\node_modules\map-stream\index.js:71:7)
at C:\Users\user\Documents\proj\node-sdk\node_modules\gulp-jshin
t\node_modules\map-stream\index.js:85:7
问题似乎在于 es.merge 的使用,因为没有它(一个处理路径),一切都按预期工作。不幸的是,我对 node.js 流没有广泛的了解,所以我无法确定这个问题的原因。我的 Node 版本是 0.10.28,gulp 3.6.2 和 event-stream 是 3.1.5