Skip to content

[Bug] fileReplacements configuration can not replace html files #10881

Closed
@idododu

Description

@idododu

Versions

Angular CLI: 6.0.0
Node: 8.11.1
Angular: 6.0.0
Windows 7

Repro steps

Reproduce git: https://github.com/idododu/ng6-filereplacements-bug

  • Step 1: add fileReplacements config in configurations block of angular.json
           "project-b": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.project-b.ts"
                },
                {
                  "replace": "src/app/home-a/home-a.component.html",
                  "with":    "src/app/home-b/home-b.component.html"
                },
                {
                  "replace": "src/app/home-a/home-a.component.ts",
                  "with":    "src/app/home-b/home-b.component.ts"
                }
              ]
            }
  • Step 2: npm run project-b to start dev server

Observed behavior

home-a.component.ts was replaced correctly.

  • home-a.component.ts in chrome source
    image
  • home-a.component.ts in my source code
    image

home-a.component.ts was not replaced

  • home-a.component.html in chrome source
module.exports = "<p>\r\n  home-a works!\r\n</p>\r\n"
  • home-a.component.html in my source code
<p>
  home-a works!
</p>
  • home-b.component.html in my source code
<p>
  home-b works!
</p>

Desired behavior

  1. Expected to see
    content of home-a.component.html should be replaced by home-b.component.html since i have configed in angular.json
{
                  "replace": "src/app/home-a/home-a.component.html",
                  "with":    "src/app/home-b/home-b.component.html"
                },
  1. Usecase
    Suppose we got two projects: Project A and Project B.
    They share the most of my source codes except HomeComponent.
    And I would like to put the codes in the same repo, and build different projects through environments configuration.

Mention any other details that might be useful (optional)

Another point: can we support glob expressions in fileReplacements configuration?

{
  "replace": "src/app/home-a/*/**",
  "with": "src/app/home-b/*/**"
}

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