Angular-CLI v6: --no-aot build option equivalent

Narm picture Narm · Jun 19, 2018 · Viewed 11.3k times · Source

I recently upgraded from Angular v5.2.4 partnered with Angular-CLI v1.7.4 to Angular v6.0.3 partnered with Angular-CLI v6.0.8.

My project requires a JIT compiler due to the use of dynamic components. As a result my build script use to be: ng build --prod --no-aot.

I need to continue to use the --prod flag to retain the benefits of the tree shaking, code minification, and dead code elimination. However, by default --prod enables AOT. The --no-aot option used to be the solution to disable AOT, yet still gain the benefits of the --prod build.

I've tried the following options and as you can see no builds have succeeded (except a standard --prod build). I am not getting any info back from the CLI either which is not very helpful:

enter image description here

I've read over the Official Angular Deployment Docs as well as the Official Angular-CLI build Wiki and have not found any information to help solve this issue.

Does anyone know what the replacement for --no-aot option is OR the new way to do a --prod build while disabling AOT?

Answer

R. Richards picture R. Richards · Jun 20, 2018

To do this from the command line, use the following options along with the --prod option.

--aot=false --build-optimizer=false

The complete command:

ng b --prod --aot=false --build-optimizer=false

If you would rather avoid doing this on the command line each time, you can change the production build options in the angular.json.

At the following path in the file

projects/your-project/achitect/build/configurations/production

Change the aot and buildOptimizer options to false. Then, you can simply run ng b --prod from the command line, and you will get a production build that doesn't include the aot and build-optimizer options.

Thanks JB and Jon!