how to use ahead-of-time compiler with angular cli webpack

北战南征 提交于 2019-11-30 03:51:15
Brocco

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!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!