html file replacement doesn't work
π 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
It would be nice if the documentation was updated with this feature, and if someone could provide an example.
Yes, the docs on --index are distinctly lacking.
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
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
}
}
}
}
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.
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.