如何在 Angular CLI 中创建和使用新的构建配置?

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

在我的 Angular.json 文件中。我有

      "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"
            }
          ]
        }
      }

当我运行ng build --prod

时执行

如何创建新配置,例如开发?

将环境配置添加到 angular.json 后,您可以使用 --configuration 选项构建它。在你的情况下 ng build --configuration=development.