Ewerton Oliva
Ewerton Oliva

Reputation: 1

Angular11: fileReplacements stopped working after angular update

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

Upvotes: 0

Views: 52

Answers (0)

Related Questions