[英]Why gulp-uglify is not working when I used ES6 syntax in angularjs
I'm trying to minify all of my AngularJS files to be compressed with gulp-uglify
. 我正在尝试将所有AngularJS文件压缩为
gulp-uglify
压缩。 But the problem is I've used ES6 syntax in my project, especially arrow function
. 但是问题是我在项目中使用了ES6语法,尤其是
arrow function
。
When I minify js file with as follow: 当我用以下方法缩小js文件时:
gulp.task('minify-scripts', function() {
return gulp.src(jsFiles)
.pipe(concat('scripts.js'))
.pipe(gulp.dest(jsDest))
.pipe(rename('scripts.min.js'))
.pipe(uglify())
.pipe(gulp.dest(jsDest));
});
for following ES6 code: 以下ES6代码:
apiService.fetchAccessToken($scope.body).then((response) => {
encountered following error: 遇到以下错误:
events.js:160 throw er;
events.js:160 throw er; // Unhandled 'error' event
//未处理的“错误”事件
But when I reversed ES6 code to traditional code: 但是当我将ES6代码反转为传统代码时:
apiService.fetchAccessToken($scope.body).then(function(response) {
Everything is working fine. 一切正常。 Please let me know what I've missed to configure something inside gulp to minify
es6
code? 请让我知道我已经错过了配置内吞的东西来缩小
es6
代码?
According to the github README of gulp-uglify, you should use uglify-es for ES6 support. 根据gulp-uglify的github自述文件 ,您应该将uglify-es用于ES6支持。
// can be a git checkout // or another module (such as
uglify-es
for ES6 support)//可以是git checkout //或其他模块(例如支持ES6的
uglify-es
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.