I have code like:
define('identity', function () {
// LOT OF CONSTANTS AND USAGE HAS BEEN REMOVED FOR BREVITY
'use strict';
var CREATE_ACCOUNT = 'CreateAccount';
var ACCOUNT = 'Account';
var CONNECT = 'Connect';
var SWITCH = 'Switch';
var FB = 'FB';
var PIPE_SEPARATOR = ' | ';
var DOT_SEPARATOR = '.';
var COMMA_SEPARATOR = ', ';
function concatenateWithDotSeparater(array) {
return concatenateWithSeparator(array,DOT_SEPARATOR);
}
function concatenateWithPipeSeparater(array) {
return concatenateWithSeparator(array,PIPE_SEPARATOR);
}
function concatenateWithCommaSeparater(array) {
return concatenateWithSeparator(array, COMMA_SEPARATOR);
}
function concatenateWithSeparator(array, separator) {
return array.join(separator);
}
return {
signUp: {
facebookConnect : concatenateWithDotSeparater([CREATE_ACCOUNT, FB, CONNECT]),
}
};
});
Essentially, I had lots of constants which were repeating and need to be concatenated to produce actual value. So, I created constants to hold repeating values and then concatenated them via function.
But when I tried to minify the JS using gulp-minify version 1.0.0 the result was like: return{signUp:{facebookConnect:e(["CreateAccount","FB","Connect"])}}
It injected actual values. How can I prevent this?
I like to get an output like: return{signUp:{facebookConnect:e([s,d,e])}}
I am using minify like:
.pipe(minify({
ext: {
src: '.js',
min: '-min.js'
}
}))
Please help.
You can avoid renaming some variables if you set option mangle where you should to set list of names you want to save unchangeble. Under the hood the
gulp-minify
packet uses theuglify-es
packet. Look at it for detailed documentation.Please try with this options: