Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular11: fileReplacements stopped working after angular update #27638

Closed
1 task
EwertonLeal opened this issue May 14, 2024 · 3 comments
Closed
1 task

Angular11: fileReplacements stopped working after angular update #27638

EwertonLeal opened this issue May 14, 2024 · 3 comments

Comments

@EwertonLeal
Copy link

EwertonLeal commented May 14, 2024

Command

build

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

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
}
}
}

Minimal Reproduction

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.

Exception or Error

No response

Your Environment

Angular CLI: 11.2.19
Node: 16.16.0       
OS: win32 x64       

Angular: 11.2.14    
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1102.18
@angular-devkit/build-angular   0.1102.18
@angular-devkit/core            11.2.18
@angular-devkit/schematics      11.2.19
@angular/cdk                    9.2.4
@angular/cli                    11.2.19
@angular/flex-layout            9.0.0-beta.31
@angular/material               9.2.4
@schematics/angular             11.2.19
@schematics/update              0.1102.19
rxjs                            6.6.7
typescript                      4.0.8

Anything else relevant?

No response

@alan-agius4
Copy link
Collaborator

Angular version 11 is not longer under support. Please see: https://angular.io/guide/releases#actively-supported-versions

@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale May 14, 2024
@EwertonLeal
Copy link
Author

Angular version 11 is not longer under support. Please see: https://angular.io/guide/releases#actively-supported-versions

Good morning, thank you for responding.

But is there a reason why "fileReplacement" replaces the files below when @angular-devkit/build-angular is in version 0.1002.3 and does not when it is in any version above?

"fileReplacements": [ { "replace": "src/assets/environments/environment.json", "with": "src/assets/environments/environment.dev-machine.json" }

@alan-agius4
Copy link
Collaborator

fileReplacements is designed for source files that are part of the TypeScript compilation process. It does not work for replacing arbitrary assets (e.g., images or json files) during the build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants