swathi anupuram swathi anupuram - 26 days ago 61
Javascript Question

GulpUglifyError:Unable to minify JavaScript

I am trying to minify my script files for which i am using gulp task runner
And I am trying gulp-uglify plugin

Code:

gulp.task('concat', function() {
return gulp.src('app/**/*.js')
// .pipe(concat('script.js'))
.pipe(uglify())
.pipe(gulp.dest('./dist/'))
});


but i am getting error as

enter image description here

when i try to run gulp task as gulp concat
Any help would be appreciated

Answer

Have you used ES6 format in your script file? If so try ES5 now because when you do gulp-uglify it doesnt understand ES6 format as of now and after that try your code

 gulp.task('concat', function() {
    return gulp.src('app/**/*.js')
        .pipe(concat('script.js'))
        .pipe(uglify())
        .pipe(gulp.dest('./dist/'))
});

and run the task gulp concat it will work