This content originally appeared on DEV Community and was authored by Gulshan Aggarwal
I have been working on a project with Next.js since last month and used the console.log statement in lots of components & files even though I don't remember. Usually, we use it to check API responses and some other areas of the application.
Making console statements public is not a good idea at all, it may bring your app at a security risk. Checking every file, and deleting the statement is very time-consuming & boring too. As a developer, we all hate boring tasks so, in the article here we discuss how you can say goodbye to console.log in your Next.js app from the Production environment in just less than 1 minute.
Sounds good! let's goooo...😎
👉 Follow the steps mentioned below -
1. Install the babel-plugin-transform-remove-console
package as a development dependency.
2. Create a .babelrc file at the root of your project, copy the below content & that's all.
{
"presets": [
"next/babel"
],
"env": {
"production": {
"plugins": [
"transform-remove-console"
]
}
}
}
🏁 This is just a short trick that I used to enhance my productivity, even you should use it next time.
I will keep sharing more tips & tricks related to web dev,stay tuned!.
Thanks for reading.
This content originally appeared on DEV Community and was authored by Gulshan Aggarwal

Gulshan Aggarwal | Sciencx (2022-06-24T04:57:42+00:00) Say Goodbye to console.log from Production environment. Retrieved from https://www.scien.cx/2022/06/24/say-goodbye-to-console-log-from-production-environment/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.