Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 360
Narm Avatar asked Jun 19 '18 21:06

Narm


People also ask

Does ng build prod use AOT?

The ng build command with the --prod meta-flag (ng build --prod) compiles with AOT by default. Why compile with AOT? With AOT, the browser downloads a pre-compiled version of the application. The browser loads executable code so it can render the application immediately, without waiting to compile the app first.

Does Angular use AOT by default?

By default, aot is set to true for new CLI applications. See the CLI command reference and Building and serving Angular apps for more information.


2 Answers

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.

The --prod build option is deprecated. Below in the updated command.

ng b -c production --aot=false --build-optimizer=false
like image 58
R. Richards Avatar answered Oct 08 '22 00:10

R. Richards


You can try this:

ng build --prod --aot=false --build-optimizer=false
like image 2
Gunjan Kumar Avatar answered Oct 08 '22 00:10

Gunjan Kumar