Angular-CLI v6: --no-aot build option equivalent
Asked Answered
K

3

14

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?

Kovacev answered 19/6, 2018 at 21:32 Comment(6)
--aot=false --build-optimizer=false should do itAncell
Indeed --aot false was already the way to do it, --no-aot isn't documented for the old version either: github.com/angular/angular-cli/wiki/1-x-build.Kept
Not tested, but editing your angular.json file, and repacing aot=true by aot=false under projects/your-project/achitect/build/configurations/production should do it. And you would just have to use ng build --prod.Clearing
The combination of --aot=false --build-optimizer=false did work. However, I like the idea of disabling AOT in the angular.json and removing the additional option. I will test that right now too.Kovacev
Your suggestion worked too, @JBNizet (well partially)! In angular.json I change aot=false and "buildOptimizer": false just like @R.Richards mentioned in his comment. With that combination I can now successfully do ng build --prod and get the same result as ng build --prod --aot=false --build-optimizer=falseKovacev
Thank you to all of you for your help in this matter! If any of you want to provide an answer I will happily accept it.Kovacev
A
25

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
Ancell answered 19/6, 2018 at 22:5 Comment(0)
M
2

You can try this:

ng build --prod --aot=false --build-optimizer=false
Mouthwatering answered 19/11, 2019 at 6:46 Comment(0)
E
0

In .npmrc file

legacy-peer-deps = true

Command Prompt

npm install 

Or

npm config set legacy-peer-deps true
npm install
Erosive answered 30/7, 2021 at 11:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.