Search code examples
angularangular-cliwebpack-2angular-aot

How to do AOT with Angular-CLI in Angular application?


Building an Angular4 project and trying to figure out how and do we need to do AOT with Angular-CLI since it runs Webpack2 behind the scenes and webpack can give us production build using ng build. So do we need to do AOT with CLI or not?

Also when we run CLI based project at our local machine, is the build rendered on localhost AOT compiled or JIT?


Solution

  • For Aot Build use

    ng build --prod
    

    This will create files in your dist folder that will be aot build.

    For a Jit build ng build is enough which will create files in your dist folder which are compiled using jit.

    and if you want to serve aot in local use ng serve --aotnormally using ng serve the files are served using jit