我正在尝试将 stream-combiner2 与我的 Gulp 4 任务一起使用,正如本食谱当前版本中所建议的那样。但是,我总是收到:
The following tasks did not complete: build:js
Did you forget to signal async completion?
我已经阅读了这个答案中关于 Gulp 4 async completion的优秀信息,但是我在我的任务中应用它时遇到了麻烦。这是我所拥有的:
const browserify = require('browserify')
const buffer = require('vinyl-buffer')
const combiner = require('stream-combiner2')
const gulp = require('gulp')
const jsDest = 'static/js'
const jsPath = 'build/js'
const jsSrc = `${jsPath}/**/*.js`
const source = require('vinyl-source-stream')
const sourcemaps = require('gulp-sourcemaps')
const uglify = require('gulp-uglify')
gulp.task('build:js', function () {
const combined = combiner.obj([
browserify({
entries: `${jsPath}/main.js`,
debug: true
}),
source(`${jsPath}/main.js`),
buffer(),
sourcemaps.init({ loadMaps: true }),
uglify(),
sourcemaps.write('./'),
gulp.dest(jsDest)
])
combined.on('error', console.error.bind(console))
return combined
})