How to use environment variable in index.html for Angular 6
You should create copy of index.html and name it index.someenv.html
.
Then in your angular.json in environment configuration setup file replacement:
"fileReplacements": [
{
"replace": "src/index.html",
"with": "src/index.someenv.html"
}
]
The angular cli will replace these files when you run your build
This answer supersedes Artyom's answer for Angular 8 and above. Add the following to your angular.json
:
"production": {
"index": {
"input": "src/index.someenv.html",
"output": "index.html"
},
},