Angular 9: file replacements doesn't work

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

Tags:

Angular