Skip to content

HTML files and fileReplacements work differently for "ng serve --prod" and "ng build --prod" #15045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gunsh opened this issue Jul 11, 2019 · 2 comments

Comments

@gunsh
Copy link

gunsh commented Jul 11, 2019

🐞 Bug report

- [ ] new
- [x] build
- [x] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

I recall this working prior to upgrading to v8.

Description

The section "fileReplacements" in "angular.json" works for "ng serve" and "ng serve --prod" but not for "ng build --prod".

🔬 Minimal Reproduction

Clone the repro app. There are two sets of files to observe:

  • environment.ts and environment.prod.ts
  • index.html and index.prod.html

File "angular.json" has the appropriate "fileReplacements" for production build for the two sets of files. The HTML files differ in the <h1> tag which clearly indicates development/production. Also, the AppComponent merely reflects "environment.production".

  1. Run the app with "ng serve", both <h1> and AppComponent show "development" as expected.
  2. Run the app with "ng serve --prod", both <h1> and AppComponent show "production" as expected.
  3. Run the app with "ng build --prod" and run the app using e.g. "serve", the <h1> shows "development" while AppComponent shows "production". Clearly not as expected. Inspecting generated "dist/index.html" shows that the file was NOT replaced.

🔥 Exception or Error

There is no error. If this feature is not supported as some people have indicated in issue #10881, then there should definitely be an error during build that the files are skipped/ignored. There is no indication that the HTML files are skipped.

It is strange that "ng serve --prod" behaves differently to "ng build --prod".

🌍 Your Environment


Angular CLI: 8.0.6
Node: 10.16.0
OS: win32 x64
Angular: 8.0.3
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.6
@angular-devkit/build-angular     0.800.6
@angular-devkit/build-optimizer   0.800.6
@angular-devkit/build-webpack     0.800.6
@angular-devkit/core              8.0.6
@angular-devkit/schematics        8.0.6
@angular/cli                      8.0.6
@ngtools/webpack                  8.0.6
@schematics/angular               8.0.6
@schematics/update                0.800.6
rxjs                              6.4.0
typescript                        3.4.5
webpack                           4.30.0

Anything else relevant?
I have tried running "ng update" to get the latest and greatest but it did not work either.

@alan-agius4
Copy link
Collaborator

Duplicate of #14599

@alan-agius4 alan-agius4 marked this as a duplicate of #14599 Jul 11, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants