Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are "enableProdMode()" and "build --prod" equivalent?

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?

like image 307
Autumn_Cat Avatar asked Jun 27 '17 13:06

Autumn_Cat


1 Answers

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.

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();
}

and in the environment file the production property is set to true.

like image 116
Poul Kruijt Avatar answered Sep 17 '22 21:09

Poul Kruijt