How to pass string constants in UglifyJS as define argument

By | May 23, 2019 | 0 Comment
Category: Javascript

If you need to pass the constant number or boolean values in UglifyJS –define option, it is very easy. The tricky part is passing the string constant. Here is a quick code snippet to show how to pass string constant.

uglifyjs “test.js” –define STRCONST='”hello is a const string”‘ –output “build.min.js”

The correct sequence is single quote + double quote + your string + double quote + single quote


About Vishal Monpara

Vishal Monpara is a full stack Solution Developer/Architect with 13 years of experience primarily using Microsoft stack. He is currently working in Retail industry and moving 1's and 0's from geographically dispersed hard disks to geographically dispersed user leveraging geographically dispersed team members.