angularangular-cliangular8angular-devkit

how to create and use a new Build configuration in Angular CLI?


In my Angular.json file. I have

      "configurations": {
        "production": {
          "fileReplacements": [
            {
              "replace": "src/environments/environment.ts",
              "with": "src/environments/environment.prod.ts"
            }
          ],
          "optimization": true,
          "outputHashing": "all",
          "sourceMap": true,
          "extractCss": true,
          "namedChunks": false,
          "aot": true,
          "progress": true,
          "buildOptimizer": true,
          "budgets": [
            {
              "type": "initial",
              "maximumWarning": "2mb",
              "maximumError": "5mb"
            }
          ]
        }
      }

This is executed when i run ng build --prod

How can I create a new configuration e.g. dev ?


Solution

  • Once you have added an environment configuration to angular.json you can build it by using the --configuration option. In your case ng build --configuration=development.