angularangular-cli

Do default angular.json options override?


My simplified angular.json config is below. I am using Angular 16. I understand the default for outputHashing in Angular is none.

Given the below config, if I execute:

ng build --configuration=development

Will outputHashing: all be applied or will outputHashing: none be applied?

This article doesn't seem to clarify the position too clearly.

{
  "projects": {
    "myproject": {
      "architect": {
        "build": {
          "options": {
            "outputHashing": "all"
          },
          "configurations": {
            "production": {
              "outputHashing": "media"
            },
            "development": {
            }
          }
        },
        "serve": {},
        "extract-i18n": {},
        "test": {},
        "lint": {}
      }
    }
  }
}

Solution

  • Consider the configurations as overrides to the config, and the options as your base options. The development config is just an empty object in your case, so it does not override anything. Here the base options come into play. Only if for a setting there is neither anything in the base options nor in the overrides, the default value is used. In your scenario, outputHashing: "all" will be used with the development configuration because it's defined in the base options and not overwritten.

    Note: Unfortunately I do not have a reputable source to back this up, but this is how it works in my experience.