Angular fileReplacements
doesn't replace files if they occur in assets
.
This code doesn't work in Angular 9 but works in version 8:
"assets": [
"src/web.config"
]
...
"fileReplacements": [
{
"replace": "src/web.config",
"with": "src/configs/web.stage.config"
}
]
How can it be fixed?
You should copy assets using the assets property instead of file replacements.
This is a simplification of my angular.json
file, showing only the relevant properties under configurations
.
{
"projects": {
"my-project": {
"architect": {
"build": {
"configurations": {
"staging": {
"assets": [
{ "glob": "**/*", "input": "src/assets/", "output": "/assets/" },
{ "glob": "web.config", "input": "src/environments/staging/", "output": "/" }
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.staging.ts"
}
]
},
"production": {
"assets": [
{ "glob": "**/*", "input": "src/assets/", "output": "/assets/" },
{ "glob": "web.config", "input": "src/environments/prod/", "output": "/" }
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
}
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With