我正在使用 browserify 来监听将多个文件编译成多个目标,就像这样(使用这个技巧):
gulp.task('js', function () {
var bundler = through2.obj(function (file, enc, next) {
browserify(file.path).bundle(function(err, res) {
file.contents = res;
next(null, file);
});
});
return gulp.src(['foo.js', 'bar.js'])
.pipe(bundler)
.pipe(uglify())
// Other pipes
.pipe(gulp.dest('./compiled'));
});
如何将这种 through2 用法与 watchify 结合起来?关于使用乙烯基源流的常见建议对我不起作用。我想生成两个文件(compiled/foo.js 和compiled/bar.js)。我不想将文件合并为一个。