An Interest In:
Web News this Week
- April 19, 2024
- April 18, 2024
- April 17, 2024
- April 16, 2024
- April 15, 2024
- April 14, 2024
- April 13, 2024
December 27, 2021 09:01 am GMT
Original Link: https://dev.to/ikeakiko/remove-console-logs-in-production-build-angular-2x-1b43
Remove console logs in production build (Angular 2.x)
Problem / Goal
For debugging, most of us often write console.log to enable us to analyze problems.
But, it is might be dangerous because there is a risk of accidentally outputting confidential information (api key, password, etc).
Therefor, we don't want to output console.log in production.
Solution Overview
Override console.log method on a function that does nothing.
(There is also another way that use webpack settings.)
Concrete Steps
Override console.log method on a function that does nothing.
app/main.ts
if (environment.production) { window.console.log = () => {};}
Original Link: https://dev.to/ikeakiko/remove-console-logs-in-production-build-angular-2x-1b43
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To