Search code examples
angularangular-cliangular-compiler-cli

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


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


Solution

  • 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.