minify es2017 with gulp
minify es2017 with gulp
嘿,伙计们,我目前正在使用uglify-gulp与babel来缩小我的js。它在es2015和es2016上工作得很好。但如果我试着做es2017,它就坏了。
有没有人知道在es2017中使用新的实验功能来最小化js的变通方法?
gulp.src('build/js/bundled/bundle.js')
.pipe(babel({
compact: false,
presets: ["es2017", "react"],
plugins: ["transform-decorators-legacy"],
}))
.pipe(uglify())
.pipe(gulp.dest('build/js/bundled'));
产生这个错误
GulpUglifyError: unable to minify JavaScript
如果我将es2017更改为es2015/es2016,它将最小化没有es2017功能的包。但是我希望能够使用这些实验性的特性并且能够缩小我的代码
我认为Uglify不能解析ES2015的一些特性,所以你需要将它们翻译成ES5 (es2017
目标节点5+)。
有了这些webpack说明,特别是预设和插件,你应该能够让它工作(至少对我来说是这样的,因为我可以通过使用es2017
来复制类似的Uglify问题):
presets: ['es2015', 'es2017', 'react'],
plugins: ['transform-runtime', 'transform-decorators-legacy', 'transform-class-properties']
相关文章:
- Fighting with FRP
- issue with FB.Event.subscribe
- geolocation-marker.js conflict with markerclusterer.js
- 当使用Watchify时,Browserify+Babelify Gulp任务没有终止
- Angular 2.0 with JavaScript or TypeScript?
- 为什么不推荐使用“with”?是否有更好或其他方法可以“下降”到对象的命名空间
- gulp-if-javascript文件,但不在gulp-useref的特定目录中
- WebComponentsJS with IE10
- gulp Iconify任务抛出错误TypeError:Path必须是字符串.收到false
- 指令的模板必须只有一个根元素:With restrict E&替换true
- Gulp: Jscs with parameter
- Gulp with browserify:找不到模块 src/js/main.js
- Gulp using gulp-data and gulp-jade with directory
- gulp-livereload with vagrant environment:livereload.js无法访问
- SASS任务在gulp with sourccomments: 'map'生成'断言失败'
- SASS + CSS Injecting with Gulp and BrowserSync
- Gulp watch with browserSync
- Webpack-Dev-Server With Gulp在代码更改后不重新加载
- minify es2017 with gulp
- Watchify with gulp不起作用