Hi I am trying to minify my app.js file using gulp uglify, I used pump to get error details and it gives me an error on Line 2
GulpUglifyError: unable to minify JavaScript
Caused by: SyntaxError: Unexpected token: name (app)
File: /Users/Alexander/OneDrive/Alexander/scripts/app.js
Line: 2
Where as Line 2 in my app.js is let app = angular.module("app", ["ngRoute"]);
here is my complete app.js file
let app = angular.module("app", ["ngRoute"]);
app.config(function ($routeProvider) {
$routeProvider
.when("/",{
templateUrl : "templates/home.html"
})
.when("/resume",{
templateUrl: "templates/resume.html"
})
.when("/contact",{
templateUrl: "templates/contact.html"
});
});
app.controller("MainController",["$scope", function ($scope) {
$scope.name = "Alexander Personal Website";
}]);
here is my gulpfile.js
var gulp = require('gulp');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var pump = require('pump');
gulp.task('compress', function (cb) {
pump([
gulp.src('scripts/*.js'),
uglify(),
gulp.dest('app')
],
cb
);
});
I have seen the Question where it says uglify doesn't work with es6 but the line where I am getting the error is also same for es5.
I hope enough detail is there. Thank you for looking into this issue.