本文介绍了如何解决Gulp上的这个缩小错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
gulp.task('minify',function(){
return gulp
.src('public / app / js / myapp.bundle.js')
.pipe(uglify())
.pipe(gulp.dest('public / app / js / myapp.bundle.min.js'));
});
该位置的代码是
setters:[],
execute:function(){$ b $ class MenuItem {//< - line 1628
有什么不对?
解决方案
UglifyJS EcmaScript 6结构。
你会可能需要首先通过一个转译器来运行JavaScript,或者找到一个知道如何处理ES6代码的缩小器。
更新2017 -06-17
设计用于ES6的UglifyJS分支现在发布为关于npm。
I'm getting below error running this command
gulp.task('minify', function () {
return gulp
.src('public/app/js/myapp.bundle.js')
.pipe(uglify())
.pipe(gulp.dest('public/app/js/myapp.bundle.min.js'));
});
Code on that location is this
setters: [],
execute: function () {
class MenuItem { // <-- line 1628
What's wrong?
解决方案
UglifyJS does not currently support EcmaScript 6 structures like classes.
You'll probably need to run your JavaScript through a transpiler step first, or find a minifier that knows what to do with ES6 code.
Update 2017-06-17
The branch of UglifyJS that is designed to work with ES6 is now published as uglify-es
on npm.
这篇关于如何解决Gulp上的这个缩小错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!