I'm trying to minify all of my AngularJS files to be compressed with gulp-uglify
. But the problem is I've used ES6 syntax in my project, especially arrow function
.
When I minify js file with as follow:
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:
apiService.fetchAccessToken($scope.body).then((response) => {
encountered following error:
events.js:160 throw er; // Unhandled 'error' event
But when I reversed ES6 code to traditional code:
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?
According to the github README of gulp-uglify, you should use uglify-es for ES6 support.
// can be a git checkout // or another module (such as
uglify-es
for ES6 support)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.