I'm minifying javascript using gulp.
My JS has objects like following
var a={"v":5}
But after minification it converts my object to following:
var a={v:5}// but I don't want it to remove quotes in keys
Because I'm using this javascript in chrome extension (basically I want to remove this error)
My gulp task is as following:
var uglify = require('gulp-uglify');
gulp.task('build1',function() {
gulp.src(['../ext/app/background.js']).on('error', function(e){
console.log("error:",e)
}).pipe(uglify({mangle:true,quote_keys:true})).on('error', function(e){
console.log("error1:",e)
}).pipe(gulp.dest('../ext/app'));
});
It's because you are passing the quote_keys
as an option instead of enclosing it in output
option in the gulpfile while using the gulp-uglify
package. Try this and you will get the desired output.
gulp.task('build1',function() {
gulp.src(['a.js']).on('error', function(e){
console.log("error:",e)
}).pipe(uglify({output:{quote_keys:true}})).on('error', function(e){
console.log("error1:",e)
}).pipe(gulp.dest('app'));
});