How to force console logs to show in --prod mode


#1

In order to debug the “white screen of death”, I need a way to see the console logs in --prod mode.
Remote debugging is useless since nothing is sent to the console.
Is there a way to keep the logs in --prod mode?


#2

Try:

npm run build --prod
npm install http-server -g
http-server ./www

Then, navigate to:

http://localhost:8100

Calls to console.log() will appear in your browser’s console, for example:

platformBrowserDynamic().bootstrapModule(AppModule).then(() => {

  if ('serviceWorker' in navigator && ENV.production) {
    navigator.serviceWorker.register('/ngsw-worker.js');
    console.log('SW registered');
  }

}).catch(error => console.log(error));

Chrome DevTools:


#3

Thanks Rob for your prompt reply. I really appreciate it.