2 ms·
schmerg and I added support for this in UglifyJS about a year ago. Use the define parameter to define values for constants, e.g. uglify --define DEBUG=true
by tav 15y ago
schmerg and I added support for this in UglifyJS about a year ago. Use the define parameter to define values for constants, e.g.
uglify --define DEBUG=true
It will then replace all uses of the DEBUG symbol to true. And when you set it to false, it will even strip away dead code like:
if (DEBUG) ...
We even added support for define-from-module which allows you to specify and use the exported symbols from a nodejs module instead of defining them on the command line. I tend to have dev.js and prod.js setup for this purpose.
Hope these features address your requirements. Apologies if we didn't make the feature visible enough. It's documented on the UglifyJS frontpage...