Currently, I am attempting to compress all of my AngularJS files using gulp-uglify
. However, I have run into a roadblock due to the fact that I have utilized ES6 syntax in my project, particularly arrow function
.
Upon trying to minify a js file with this code:
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));
});
I encountered an error when trying to minify the following ES6 code snippet:
apiService.fetchAccessToken($scope.body).then((response) => {
The error displayed was:
events.js:160 throw er; // Unhandled 'error' event
Interestingly, switching back to traditional code instead of ES6 code like so:
apiService.fetchAccessToken($scope.body).then(function(response) {
resolved the issue. Can anyone guide me on what steps I may have overlooked within the gulp configuration for minifying es6
code?