是"enableProdMode()";和"build --prod"相等的? [英] Are "enableProdMode()" and "build --prod" equivalent?

查看:291
本文介绍了是"enableProdMode()";和"build --prod"相等的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个愚蠢的问题.我想知道如何加快我的应用程序.在大多数情况下,流行的方法是在构建过程中使用--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.jsonenvironments数组中定义为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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆