3

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?

Peter
  • 10,492
  • 21
  • 82
  • 132

1 Answers1

4

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

Peter
  • 10,492
  • 21
  • 82
  • 132
Rahul Singh
  • 19,030
  • 11
  • 64
  • 86
  • i found out that aot is by default in prod. so specifying --aot doesn't make any effect. see this https://stackoverflow.com/a/42011373/5346095 – Peter Jul 18 '17 at 10:18
  • @VishalGulati yes vishal by default --prod is aot now , but i think these changes rolled out recently and explicitly specifying --aot dosn't do any harm so i didnot mention – Rahul Singh Jul 18 '17 at 10:19