0

My team and I are updating the Angular version of our app. We were using version 10.2.3 and migrated to 11.2.19 in angular/cli

Before updating, our environments files were replaced by fileReplacements

But now that we've updated them, they no longer work.

Package.json

"dependencies": {
    "@amcharts/amcharts4": "^4.10.19",
    "@angular-devkit/build-angular": "^0.1002.3",
    "@angular/animations": "^11.2.14",
    "@angular/cdk": "^9.2.4",
    "@angular/common": "^11.2.14",
    "@angular/compiler": "^11.2.14",
    "@angular/core": "^11.2.14",
    "@angular/flex-layout": "^9.0.0-beta.31",
    "@angular/forms": "^11.2.14",
    "@angular/localize": "^11.2.14",
    "@angular/material": "^9.2.4",
    "@angular/platform-browser": "^11.2.14",
    "@angular/platform-browser-dynamic": "^11.2.14",
    "@angular/router": "^11.2.14",
    "@aspnet/signalr": "^3.0.0-preview6.19307.2",
    //-------------------//
  },
  "devDependencies": {
    "@angular/cli": "^11.2.19",
    "@angular/compiler-cli": "^11.2.14",
    "@angular/language-service": "^11.2.14",
    "@fortawesome/fontawesome-free": "^5.15.3",
    "@types/crypto-js": "^3.1.47",
    "@types/jasmine": "^2.8.17",
    "@types/jasminewd2": "^2.0.9",
    "@types/jspdf": "^2.0.0",
    "@types/node": "^12.20.15",
    "codelyzer": "^5.1.2",
    "g": "^2.0.1",
    "http-server": "^0.12.3",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.4.3",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~7.0.0",
    "tslint": "~6.1.0",
    "typescript": "~4.0.8",
    "webpack-bundle-analyzer": "^3.9.0"
  }

angular.json

"configurations": {
            "production": {
              "budgets": [
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "20kb"
                }
              ],
              "fileReplacements": [
                {
                  "replace": "src/assets/environments/environment.json",
                  "with": "src/assets/environments/environment.prod.json"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true
            },
            "dev": {
              "budgets": [
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "20kb"
                }
              ],
              "fileReplacements": [
                {
                  "replace": "src/assets/environments/environment.json",
                  "with": "src/assets/environments/environment.dev.json"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true
            },
            "dev-machine": {
              "budgets": [
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "20kb"
                }
              ],
              "fileReplacements": [
                {
                  "replace": "src/assets/environments/environment.json",
                  "with": "src/assets/environments/environment.dev-machine.json"
                }
              ]
            },
            "design-machine": {
              "budgets": [
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "20kb"
                }
              ],
              "fileReplacements": [
                {
                  "replace": "src/assets/environments/environment.json",
                  "with": "src/assets/environments/environment.dev-machine.json"
                }
              ],
              "sourceMap": false
            }
          }
        }

We noticed that when returning @angular-devkit/build-angular to version 0.1002.3, the replace happens again, but if we use the version suggested by the Angular update (version 0.1102.18) it no longer works.

it should literally swap the environment.json files for environment.dev-machine.json when building. however, this exchange does not happen. I've already tested all versions between 0.1002.3 and 0.1102.19 of @angular-devkit/build-angular

3
  • 1
    Could you edit the question to clarify what you mean by "they don't work"? Is there error output that you can paste to show at what type of error it is and at what point it occurs? Commented May 14, 2024 at 4:19
  • it should literally swap the environment.json files for environment.dev-machine.json when building. however, this exchange does not happen. I've already tested all versions between 0.1002.3 and 0.1102.19 of @angular-devkit/build-angular Commented May 14, 2024 at 11:59
  • it's a little odd that your environment files are in the assets folder. Could it be that those files are being output after the "file replacement" happens... then something uses a path to the static file? Commented May 14, 2024 at 17:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.