默认的 angular.json 选项会覆盖吗?

问题描述 投票:0回答:1

我的简化

angular.json
配置如下。我正在使用 Angular 16。我了解 Angular 中
outputHashing
的默认值是
none

鉴于以下配置,如果我执行:

ng build --configuration=development

会应用

outputHashing: all
还是会应用
outputHashing: none

这篇文章似乎没有太清楚地阐明立场。

{
  "projects": {
    "myproject": {
      "architect": {
        "build": {
          "options": {
            "outputHashing": "all"
          },
          "configurations": {
            "production": {
              "outputHashing": "media"
            },
            "development": {
            }
          }
        },
        "serve": {},
        "extract-i18n": {},
        "test": {},
        "lint": {}
      }
    }
  }
}
angular
1个回答
0
投票

configurations
视为配置的 覆盖,并将
options
视为基本选项。在您的情况下,
development
配置只是一个空对象,因此它不会覆盖任何内容。这里基本选项开始发挥作用。仅当某个设置的基本选项和覆盖选项中都没有任何内容时,才会使用默认值。在您的场景中,
outputHashing: "all"
将与
development
配置一起使用,因为它是在基本选项中定义的并且不会被覆盖。

注意:不幸的是,我没有可靠的消息来源来支持这一点,但这就是我的经验。

© www.soinside.com 2019 - 2024. All rights reserved.