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:
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?
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.
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.
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
You can try this:
ng build --prod --aot=false --build-optimizer=false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With