angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

html file replacement doesn't work

Open diogen737 opened this issue 7 years ago β€’ 26 comments

🐞 Bug report

Command (mark with an x)

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

Description

After upgrading to Angular 8 file replacement stopped working for html files.

πŸ”¬ Minimal Reproduction

https://github.com/diogen737/fileReplacement-test

Expexted behavior

since there's html replacement config in angular.json after ng build --prod I expect to see
"this is prod index" on top of the page (localhost:8080/tester) which is present in index.prod.html and absent in index.html from which I conclude that html filre replacement is not working anymore.

🌍 Your Environment


Angular CLI: 8.0.0
Node: 12.3.1
OS: linux x64
Angular: 8.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

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

diogen737 avatar May 30 '19 21:05 diogen737

It would be nice if the documentation was updated with this feature, and if someone could provide an example.

chrispoupart avatar Jul 31 '19 19:07 chrispoupart

Yes, the docs on --index are distinctly lacking.

tomwhite007 avatar Aug 02 '19 12:08 tomwhite007

Had to use @boban984 answer to make it work. If you just let the index.prod.html in the root folder, and use it with --index, it will not be renamed properly... Don't get it, was working fine before and just realized today that our prod file was not the expected one 😫🀬Not cool

schankam avatar Sep 01 '19 15:09 schankam

Example of https://github.com/angular/angular-cli/pull/15010 configuration:

"architect":{
  "build": {
    "options": {
     "index": "src/index.html", //non-prod
    },
    "configurations": {
      "production":{
      "index": { //prod index replacement
        "input": "src/index.prod.html",
        "output": "index.html
      }
    }
  }
}

Nodarii avatar Sep 02 '19 12:09 Nodarii

I almost pushed our app to production with wrong index.html :(

@Nodarii answer works after deleting $schema -property (which is not nice) from angular.json. Schema seems outdated because it says that index should be a string.

kettunen avatar Sep 21 '19 17:09 kettunen

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.