Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
December 27, 2021 09:01 am GMT

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:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To