Reputation: 2084
I'm outputting a lot a internal info through extensive use of console.log()
. Is there a way to change the .log()
command for my --prod
builds in Angular?
Upvotes: 1
Views: 1970
Reputation: 2084
Building off of Yash Rami's answer, I found that I needed to use window.console.log()
in main.ts.
if(environment.production){
window.console.log = function() {}
enableProdMode();
}
Upvotes: 4
Reputation: 2327
you need to write this in main.ts. I hope it helps you out
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
console.log = function() {} // this will be disable all the logs in production mode
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.log(err));
Upvotes: 1