is there a way to use AOT with angular cli?
I've installed the modules (@angular/compiler @angular/compiler-cli) and when I type ngc -p scr it creates the ngFactory.ts files and compiles it to dist/tsc-out (angular cli default in tsconfig)
not sure how to proceed from here :)
Cheers
Han
All recent beta versions of the Angular CLI support AoT via the following:
ng serve --aot
ng build --aot
#and of course
ng build --prod --aot
Note: As of Angular CLI 1.0.0-beta.28 (released February 1st, 2017), --aot
is on by default if --prod
is specified.
Angular-cli beta 17 now supports --aot :) !
See my tests on a brand new project (with nothing in it so) :
EDIT 1 : 28 november 2016 :
Since beta 21, AOT works with lazy loaded modules :) !
I gave some more details here : https://stackoverflow.com/a/40788258/2398593
EDIT 2 : 5 may 2017 :
The cli is compiling with AOT by default if you use --prod
.
(since months but an upvote reminded me of that post !)
EDIT 3 : 27 July 2017 :
If you want to reduce your bundle size even more, it's now possible by running the build with --build-optimizer
. On a small app, I went from 1.3Mb to 864Kb!
来源:https://stackoverflow.com/questions/39167600/how-to-use-ahead-of-time-compiler-with-angular-cli-webpack