Skip to content

[9.0.1] ng build file replacements don't work after update to v9 #16916

@SansDK

Description

@SansDK

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, the previous version in which this bug was not present was the latest angular-cli v8 release (v8.3.25)

Description

I have a `config.js` file which has some settings in it, and it should be replaced by a production `config.js` when performing a production build.

This worked fine, until I upgraded to angular-cli v9. I don't get errors or warnings, but the config.js in the dist folder after building is the non-prod version, while I would expect the prod version.

In my angular.json file, I have the following:

...
"configurations": {
  "production": {
    "fileReplacements": [
      {
        "replace": "src/config.js",
        "with": "src/prod/config.js"
      }
    ]
  }
}

The command ng build --prod doesn't cause the file to be replaced, and neither does ng build --configuration=production.

🔬 Minimal Reproduction

  1. Create a new project with the latest Angular v8 & Angular CLI v8 release.
  2. Add the file replacement config & files like above.
  3. Run ng build --prod. File replacement works now.
  4. Update to Angular & Angular CLI 9 (run ng update @angular/core @angular/cli)
  5. Run ng build --prod again. The file doesn't get replaced anymore (original config.js will be present in the dist folder). ❌

🌍 Your Environment

Angular CLI: 9.0.1
Node: 13.0.1
OS: win32 x64

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

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.1
@angular-devkit/build-angular     0.900.1
@angular-devkit/build-optimizer   0.900.1
@angular-devkit/build-webpack     0.900.1
@angular-devkit/core              9.0.1
@angular-devkit/schematics        9.0.1
@angular/cli                      9.0.1
@ngtools/webpack                  9.0.1
@schematics/angular               9.0.1
@schematics/update                0.900.1
rxjs                              6.5.4
typescript                        3.7.5
webpack                           4.41.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions