I have console.log all over the place. Removing them all is not good as I might need them again. Is there way I can do something like this for entire react app?
if(env === 'production'){
console.log= function(){}
}
In your index.js
file, check if you're running in dev or production mode.
Disable console.log if you're in production mode.
if (process.env.NODE_ENV !== "development")
console.log = () => {};
Given you are using React, it is likely that you are already using babel as a part of your build process.
You can use this babel plugin to remove all the console.* function invocations in the build phase.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With