I am using gulp and gulp-uglify to minify my javascript code.
Gulp
var uglify= require('gulp-uglify');
gulp.task('javascript', function() {
return gulp.src('./scripts/*.js')
.pipe(uglify())
.pipe(gulp.dest('./'));
});
Original javascript
var Site = Site || {};
Site.Code = {
obj: new ThirdPartyObject(),
init: function() {
obj.thirdPartyMethod();
}
};
Minified javascript
var Site = Site || {};
Site.Code = {obj: new ThirdPartyObject,init: function() {
obj.thirdPartyMethod()
}};
The minifier is removing the parentheses for obj: new ThirdPartyObject
and therefore my code breaks when I make the call obj.thirPartyMethod()
.
How can I fix this?