title: Angular 8 how to build an app with a different environment
body: <p>It seems after recently upgrading from angular 7 to angular 8 my app does not build properly with different environments. </p>
  
  <p>For example i want to build using the test environment.</p>
  
  <pre><code>npm run build --configuration=test
  </code></pre>
  
  <p><strong>angular.json</strong></p>
  
  <pre><code>"configurations": {
                  "production": {
                      "index": "src/production/index.html",
                      "optimization": true,
                      "outputHashing": "all",
                      "sourceMap": false,
                      "extractCss": true,
                      "namedChunks": false,
                      "aot": true,
                      "extractLicenses": true,
                      "vendorChunk": false,
                      "buildOptimizer": true,
                      "fileReplacements": [
                          {
                              "replace": "src/environments/environment.ts",
                              "with": "src/environments/environment.prod.ts"
                          }
                      ]
                  },
                  "test": {
                      "index": "src/test/index.html",
                      "optimization": true,
                      "outputHashing": "all",
                      "sourceMap": false,
                      "extractCss": true,
                      "namedChunks": false,
                      "aot": true,
                      "extractLicenses": true,
                      "vendorChunk": false,
                      "buildOptimizer": true,
                      "fileReplacements": [
                          {
                              "replace": "src/environments/environment.ts",
                              "with": "src/environments/environment.test.ts"
                          }
                      ]
                  }
              }
          },
  </code></pre>
  
  <p>However this doesen;'t work and reverts back to the default environment file.</p>
  
  <p><strong>environment.ts</strong></p>
  
  <pre><code>export const environment = {
      production: false,
      build: 'Local',
      ...
  };
  </code></pre>
  
  <p><strong>environment.test.ts</strong></p>
  
  <pre><code>export const environment = {
      production: false,
      build: 'Test',
      ...
  };
  </code></pre>