I was reading related questions and I found this one, but my question is how can I switch from development to production mode. There are some differences between the modes w
Most of the time prod mode is not needed during development time. So our workaround is to only enable it when it is NOT localhost.
In your browsers' main.ts where you define your root AppModule:
const isLocal: boolean = /localhost/.test(document.location.host);
!isLocal && enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
The isLocal can also be used for other purposes like enableTracing for the RouterModule for better debugging stack trace during dev phase.