Say Goodbye to console.log from Production environment

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…


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

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.

goodbye


This content originally appeared on DEV Community and was authored by Gulshan Aggarwal


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » Say Goodbye to console.log from Production environment." Gulshan Aggarwal | Sciencx - Friday June 24, 2022, https://www.scien.cx/2022/06/24/say-goodbye-to-console-log-from-production-environment/
HARVARD
Gulshan Aggarwal | Sciencx Friday June 24, 2022 » Say Goodbye to console.log from Production environment., viewed ,<https://www.scien.cx/2022/06/24/say-goodbye-to-console-log-from-production-environment/>
VANCOUVER
Gulshan Aggarwal | Sciencx - » Say Goodbye to console.log from Production environment. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/06/24/say-goodbye-to-console-log-from-production-environment/
CHICAGO
" » Say Goodbye to console.log from Production environment." Gulshan Aggarwal | Sciencx - Accessed . https://www.scien.cx/2022/06/24/say-goodbye-to-console-log-from-production-environment/
IEEE
" » Say Goodbye to console.log from Production environment." Gulshan Aggarwal | Sciencx [Online]. Available: https://www.scien.cx/2022/06/24/say-goodbye-to-console-log-from-production-environment/. [Accessed: ]
rf:citation
» Say Goodbye to console.log from Production environment | Gulshan Aggarwal | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.