[英]Gulp, Reactify, and Babelify not transforming together
This is my gulpfile code: 这是我的gulpfile代码:
gulp.task('react', function () {
browserify('app/src/main.jsx')
.transform(reactify)
.transform(babelify)
.bundle()
.pipe(source('app.js'))
.pipe(streamify(uglify()))
.pipe(gulp.dest('dist/js/'));
});
Only the first transform statement runs, and therefor throws an error due to the lack of additional transform (I'm writing in ES6 and JSX w/ react). 只运行第一个转换语句,因此由于缺少额外的转换而抛出错误(我在ES6和JSX中编写w / react)。
I'm at a complete loss and would really appreciate help. 我完全失去了,真的很感激帮助。
Reactify should no longer be used. 不应再使用Reactify。 You don't say what version you are on, but as of Babel 6 "preset's" are the standard way to achieve compilation. 你没有说出你的版本,但截至Babel 6 “预置版”是实现编译的标准方法。
Run the following 运行以下
npm install save-dev babel-preset-react babel-preset-es2015
You should also make sure Babelify is up to date. 您还应该确保Babelify是最新的。 Then your Gulp config becomes 那么你的Gulp配置就变成了
var babelify = require("babelify");
gulp.task('react', function () {
browserify('app/src/main.jsx')
.transform(babelify, {presets: ["es2015", "react"]})
.bundle()
.pipe(source('app.js'))
.pipe(streamify(uglify()))
.pipe(gulp.dest('dist/js/'));
});
See the options page for more information. 有关更多信息,请参阅选项页面 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.