fileReplacements should allow all file types

🚀 Feature request

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc


I want to have a different robots.txt on my production system, than I have on my staging environment.

Describe the solution you’d like

I want to add a simpel fileReplacements to the angular.json for production.

"fileReplacements": [
            "replace": "src/environments/environment.ts",
             "with": "src/environments/"
             "replace": "src/robots.txt",
             "with": "src/"

But this does not work due to a pattern check:

Schema validation failed with the following errors:
  Data path ".fileReplacements[1]" should NOT have additional properties(replace).
  Data path ".fileReplacements[1].replace" should match pattern "\.(([cm]?j|t)sx?|json)$".
  Data path ".fileReplacements[1]" should match exactly one schema in oneOf.

Therefore, my feature request is to enable this functionality for all file types. This limitation does not make sense in my opinion.

Describe alternatives you’ve considered

An alternative would be to update my build pipeline for production. So that src/ is moved to src/robots.txt bevore running the compiler. But I think it is better to have all file replacements at one place.

1 possible answer(s) on “fileReplacements should allow all file types

  1. Hi @MrKrabat,

    Thanks for this request. fileReplacements only works for source files which are part of the TypeScript program. Supporting assets in fileReplacements would require a seperate implementation which is currently not in the Angular CLI roadmap.

    In this case the recommended approach is to use the assets option #16779 (comment).

    Thanks for your understanding.