【发布时间】:2015-10-13 17:05:02
【问题描述】:
我有一个 React 组件,我一直在导出到一个捆绑文件。我已经使用 babelify 成功地转换了它,但是,我现在想在它上面运行 envify。我似乎无法弄清楚如何使用 browserify 运行多个转换。我认为这一定是可能的,但我不知道我的语法是否略有偏差,或者我是否需要编写自定义转换,或者我是否应该在我的 package.json 中指定转换。这是我的 gulp 文件中的代码:
var bundleComponent = function(bundler, source, component) {
//bundler is just browserify('./client/components/TVScheduleTab/render.js')
gutil.log('Bundling ' + component)
return bundler
//this throws an error
.transform(babelify, envify({
NODE_ENV: 'production'
}))
.bundle()
.on('error', function(e){
gutil.log(e);
})
.pipe(source)
.pipe(gulp.dest('output/'));
};
【问题讨论】:
标签: node.js reactjs gulp browserify