I've created some gulp tasks to assist in building my web project. One of the tasks involves minifying js files. Here is the task code snippet:
gulp.task('minify' , function() {
console.log('Copy minified js ');
return gulp.src('dist/www/**/*.js'])
.pipe(uglify().on('error', function(e){
console.log(e);
}))
.pipe(gulp.dest('dist/www'));
});
When I run the task by using gulp minify
, an error is thrown:
{ [Error: E:XXXXXX\dist\tmp\bootstrap.js: SyntaxError: Unexpected token: name (mainModule)]
message: 'E:XXXXXX\\dist\\tmp\\bootstrap.js: SyntaxError: Unexpected token: name (mainModule)',
fileName: 'E:XXXXXX\\dist\\bootstrap.js',
lineNumber: 1,
stack: 'Error\n at new JS_Parse_Error (eval at <anonymous> (E:XXXXXX\gfgfgfgf\\gulp-uglify\\node_modules\\uglify-js\\tools\\node.js:28:1), <anonymous>:1534:18)\n at js_error (eval at <anonymous> (
This is the content of the bootstrap.js file causing the issue:
import mainModule from './src/main';
angular.element(document).ready(function() {
angular.bootstrap(document, [mainModule.name], { strictDi: true });
});
I need help understanding why this isn't working as expected. Any insights would be greatly appreciated!
Thank you!