Cannot uglify on Gulp
Opened this issue · 1 comments
jcfrane commented
Hi,
I was trying to uglify my vendor files with gulp.
It produces this error:
GulpUglifyError: unable to minify JavaScript
Caused by: SyntaxError: Unexpected token: name (Commented)
When I tried to remove angular-wamp with my dependency the error is gone.
So I suspect that angular-wamp must be the cause.
Heres my gulp task
//build prod scripts
gulp.task('build', [], function() {
// build vendors
var vb = browserify({
debug: true
});
vendors.forEach(function(vendor) {
vb.require(vendor);
});
vb
.bundle()
.pipe(source('vendors.js'))
.pipe(buffer())
.pipe(uglify({
mangle: false
}))
.pipe(gulp.dest('./web/dist/js/'))
;
var b = browserify({
entries: './web/app/gol88/app.module.js',
debug: true,
paths: ['./web/app/gol88/**/*.js'],
});
b.transform(ngAnnotate);
return b
.external(vendors)
.bundle()
.on('error', swallowError)
.pipe(source('bundle.js'))
//.pipe(gAnnotate())
.pipe(buffer())
.pipe(uglify({
mangle: false
}))
.on('error', swallowError)
.pipe(gulp.dest('./web/dist/js/'));
});
Why is that so?
frankadrian commented
Hi @jcfrane, I also experienced this error and it turns out that the autobahn.js library is making use of ES6 syntax wich the uglifier can not handle. I had to add another step to transpile to ES5 (via babel) and then the minification works!