How to enable production mode?

后端 未结 14 1216
忘掉有多难
忘掉有多难 2020-11-29 16:44

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

14条回答
  •  鱼传尺愫
    2020-11-29 17:22

    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.

提交回复
热议问题