是“enableProdMode()"和“构建 --prod"相等的? [英] Are "enableProdMode()" and "build --prod" equivalent?
问题描述
我有一个愚蠢的问题.我想知道如何加速我的应用程序.在大多数情况下,流行的一种是在构建期间使用 --prod
标志.但我也找到了一个建议来启用 Angular 生产模式enableProdMode();
在 main.ts
中.这些动作是否相同并触发相同的机制?
I have one silly question. I'm wondering about ways to speed up my app. In most cases the popular one is to use --prod
flag during build. But also I found an advice to enable Angular production mode with
enableProdMode();
in main.ts
. Are these actions the same and trigger the same mechanism?
推荐答案
--prod
标志触发 --environment=prod
标志(除其他外).这意味着编译时会使用.angular-cli.json
的environments
数组中定义为prod
的环境文件.
The --prod
flag triggers the --environment=prod
flag (among other things). This means that the environment file defined as prod
in the environments
array of the .angular-cli.json
is used during compilation.
如果你有默认的 main.ts
这确实意味着它运行 enabledProdMode()
.因为他们用它来触发它:
If you have the default main.ts
this will indeed mean it runs enabledProdMode()
. Because they use this to trigger it:
if (environment.production) {
enableProdMode();
}
在环境文件中,production
属性设置为 true
.
and in the environment file the production
property is set to true
.
这篇关于是“enableProdMode()"和“构建 --prod"相等的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!