所以我试图使用babelify而我无法使其正常工作?我错过了什么吗?在示例中,这是我的任务之一。我添加了babelify,它工作正常,现在我需要添加browserify。谢谢!
const config = require('./gulp.config.js')();
const gulp = require('gulp');
const gulpLoadPlugins = require('gulp-load-plugins');
const plugs = gulpLoadPlugins();
const bs = require('browser-sync');
const env = process.env.NODE_ENV || 'local';
const merge = require('merge-stream');
const imagemin = require('gulp-imagemin');
const browserify = require('browserify');
const babelify = require('babelify');
const clean = require('gulp-clean');
const eventStream = require('event-stream');
const optimize = false;
const babel = require('gulp-babel');
gulp.task('scripts-app', ['compile-jade'], () => {
const scriptsStream = gulp.src(config.appFolder + '**/*.js'),
templateCacheStream = gulp.src(config.appFolder + '**/*.html')
.pipe(plugs.angularTemplatecache(config.templateCache.file, config.templateCache.options));
console.log(plugs.order(config.jsOrder));
return eventStream.merge(templateCacheStream, scriptsStream)
.pipe(plugs.order(config.jsOrder))
.pipe(plugs.concat(`${config.projectName}.js`))
/*.pipe(browserify({
insertGlobals: true,
debug: true
}))*/
.pipe(babel({
presets: ['es2015']
}))
.pipe(plugs.if(optimize, plugs.uglify()))
.pipe(gulp.dest(config.build));
});
这是我运行任务时得到的错误日志,显然我做错了
[10:39:33] 'scripts-app' errored after 90 ms
[10:39:33] TypeError: eventStream.merge(...).pipe(...).pipe(...).pipe(...).pipe is not a function
at Gulp.<anonymous> (/home/hb/apps/suggestions/gulpfile.babel.js:83:6)
at module.exports (/home/hb/apps/suggestions/node_modules/orchestrator/lib/runTask.js:34:7)
at Gulp.Orchestrator._runTask (/home/hb/apps/suggestions/node_modules/orchestrator/index.js:273:3)
at Gulp.Orchestrator._runStep (/home/hb/apps/suggestions/node_modules/orchestrator/index.js:214:10)
at /home/hb/apps/suggestions/node_modules/orchestrator/index.js:279:18
at finish (/home/hb/apps/suggestions/node_modules/orchestrator/lib/runTask.js:21:8)
at /home/hb/apps/suggestions/node_modules/orchestrator/lib/runTask.js:52:4
at f (/home/hb/apps/suggestions/node_modules/once/once.js:17:25)
at DestroyableTransform.onend (/home/hb/apps/suggestions/node_modules/end-of-stream/index.js:31:18)
at emitNone (events.js:91:20)
/home/hb/apps/suggestions/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:612
var ret = dest.write(chunk);
^
TypeError: dest.write is not a function
at DestroyableTransform.ondata (/home/hb/apps/suggestions/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:612:20)
at emitOne (events.js:96:13)
at DestroyableTransform.emit (events.js:191:7)
at addChunk (/home/hb/apps/suggestions/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:284:12)
at readableAddChunk (/home/hb/apps/suggestions/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:271:11)
at DestroyableTransform.Readable.push (/home/hb/apps/suggestions/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:238:10)
at DestroyableTransform.Transform.push (/home/hb/apps/suggestions/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:146:32)
at DestroyableTransform.endStream [as _flush] (/home/hb/apps/suggestions/node_modules/gulp-concat/index.js:96:10)
at DestroyableTransform.<anonymous> (/home/hb/apps/suggestions/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:138:49)
at Object.onceWrapper (events.js:293:19)