I have a requirement to minify the constant values in the javascript project I am working on.
Currently I define the constants as something like this:
export const Constants = {
I_AM_CONSTANT: 'hello',
ANOTHER_CONSTANTS: 10,
YET_ANOTHER_CONSTANTS: false,
NO_MORE_CONSTANT: 'end'
};
and I put this object into a separate file.
Then I use UglifyPlugin of WebPack to minify the codes.
But what I get is something like
e.Constants = {
I_AM_CONSTANT: 'hello',
ANOTHER_CONSTANTS: 10,
YET_ANOTHER_CONSTANTS: false,
NO_MORE_CONSTANT: 'end'
};
It's like no minification effect at all. Can anyone tell me what is the correct way to do the minifications for these constants? How can I change my code? I also would like to know some best practice of writing constant values in javascript if possible.