Uglify an anonymous function
Closed this issue · 1 comments
waitingduck commented
Hi, I happen to have a problem when uglify an anonymous function. I am developing a chrome extension, and I need to insert a script to some webpage to retrieve some information(like width and height).
So If I have a script someScript.js
(function() {
//do something here
return {
//some object
}
}());
After I uglify with this code
pipes.moveProdScripts = function() {
return gulp.src(paths.scripts)
.pipe(babel({presets: [es2015]}))
.pipe(plugins.uglify({mangle: false}))
.pipe(gulp.dest('dist'));
};
I will get
!function() {
// do something here
return {
//some object
}
}();
The above code will return false whatever it return inside the function.
Is there any work around to keep it not using "!" but still minify the code?
gulp version: 3.9.1
gulp-uglify version: 2.0.0
Thanks you
terinjokes commented
Try passing options similar to the following:
var opts = {
compress: {
negate_iife: false
}
};