是"enableProdMode()";和"build --prod"相等的? [英] Are "enableProdMode()" and "build --prod" equivalent?
问题描述
我有一个愚蠢的问题.我想知道如何加快我的应用程序.在大多数情况下,流行的方法是在构建过程中使用--prod
标志.但是我也找到了一个建议以启用Angular生产模式
main.ts
中的enableProdMode();
.这些动作是否相同并触发相同的机制?
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()";和"build --prod"相等的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!