Angular 13: Disable aot when running ng-serve

Viewed 527

AOT is on by default since Angular 9, I tried to run in JIT mode by adding the option "--aot=false" that throws error "Unknown option --aot". In angular.json file, I tried to add "aot": false under "serve: options", but this gives warning "property aot is not allowed". How can I disable AOT by default when running ng serve only? This is my angular.json file:

  "architect": {
    "build": {
      "builder": "@angular-devkit/build-angular:browser",
      "options": {
        "outputPath": "dist/ProjectName",
        "index": "src/index.html",
        "main": "src/main.ts",
        "polyfills": "src/polyfills.ts",
        "tsConfig": "tsconfig.app.json",
        "inlineStyleLanguage": "scss",
        "assets": [
          "src/favicon.ico",
          "src/assets"
        ],
        "styles": [
          "src/global-styles/styles.scss"
        ],
        "scripts": []
      },
      "configurations": {
        "production": {
          "budgets": [
            {
              "type": "initial",
              "maximumWarning": "500kb",
              "maximumError": "1mb"
            },
            {
              "type": "anyComponentStyle",
              "maximumWarning": "2kb",
              "maximumError": "4kb"
            }
          ],
          "fileReplacements": [
            {
              "replace": "src/environments/environment.ts",
              "with": "src/environments/environment.prod.ts"
            }
          ],
          "outputHashing": "all"
        },
        "development": {
          "buildOptimizer": false,
          "optimization": false,
          "vendorChunk": true,
          "extractLicenses": false,
          "sourceMap": true,
          "namedChunks": true
        }
      },
      "defaultConfiguration": "production"
    },
    "serve": {
      "builder": "@angular-devkit/build-angular:dev-server",
      "configurations": {
        "production": {
          "browserTarget": "WebUINext:build:production"
        },
        "development": {
          "browserTarget": "WebUINext:build:development"
        }
      },
      "defaultConfiguration": "development",
      "options": {
          // No aot property allowed here
      }
    }
  } 
1 Answers

Try adding the option in build.configutations in angular.json

"architect": {
    "build": {
      "configurations": {
         "development": {
           "aot": false,
           "buildOptimizer": false
           ...
         },
         ...
      },
      ...
    },
    ...
Related