angular-cli: AoT compilation with ng serve by default

acalvo picture acalvo · Jul 5, 2018 · Viewed 7.8k times · Source

In Angular CLI, ng serve uses JiT and the flag --aot is required in order to use AoT compilation.

Is it possible to make that ng serve uses AoT by default and JIT is only used when --aot=false flag is passed?

Answer

David picture David · Jul 5, 2018

Edit: starting with angular 9, aot compilation is enabled by default in development environment (see documentation)

In angular 6, you can specify default options for the serve target, so you can add aot: true in that section and by default ng serve will use aot

"serve": {
      "builder": "@angular-devkit/build-angular:dev-server",
      "options": {
        "browserTarget": "project:build",
        "aot": true
      },
      "configurations": {