【问题标题】:how to create and use a new Build configuration in Angular CLI?如何在 Angular CLI 中创建和使用新的构建配置?
【发布时间】:2019-12-27 00:29:54
【问题描述】:

在我的 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 angular-cli angular8 angular-devkit


    【解决方案1】:

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

    【讨论】:

    • 谢谢,这正是我想要的,有没有像 production 一样的缩写 --prod
    • 如果这就是您要查找的全部内容,只需在 package.json 中的“脚本”中添加一行,例如,您可以只说 npm (or yarn) boom,它会运行 "scripts": { "boom": "ng build --c=development"}跨度>
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-07
    • 2019-11-03
    • 2018-04-18
    • 2019-03-01
    • 1970-01-01
    • 2017-07-19
    • 2023-03-10
    相关资源
    最近更新 更多