I would like to:
- embed debugging reports in my code, which I want to turn on and off during development; and
- then these statements are completely excluded in the production process.
In order to delete logs for production, I saw that the React project itself uses this idiom:
if ("production" !== process.env.NODE_ENV) {
// warn or log or whatever
}
By compiling the modules with process.env.NODE_ENV
installed on "production"
, and then launching the bundle through a dead code ejector, such as UglifyJS, the logs will be excluded as inaccessible.
This is good, but are there more flexible solutions? I think something like a debug()
Node module , or indeed some more powerful ones, such as the Java Registration API.
I am wondering why I do not find a module that combines the approach ("production" !== process.env.NODE_ENV)
with debug()
.