In angular.json
您可以配置要使用的索引文件(我使用的是 Angular 8):
"projects": {
"projectName": {
"architect": {
"build": {
"options": {
"index": "src/index.html", // this is the default location (also for ng serve)
"configurations": {
"production": {
"index": "index-prod.html" // this is the prod version (you can also link it to /prod/index.html or whatever: it will be placed in the dist root folder with the provided name)
},
"development": {
"index": "index-whatever.html" // this is the version for ng build --configuration=development`
}
}
}
}/*, UPDATED: THIS DOESN'T WORK
"serve": {
"index": "dev/index.html" // file to be used in ng serve
}*/
}
}
}
据我所知,这些都不是"index"
s 是强制性的,除了第一个
旁注:这是我刚刚尝试过的一些尝试、构建和ng serve
s。我在任何文档中都没有找到它。
检查一下并告诉我。
===========
2019 年 10 月 19 日更新:
我注意到上面报告的配置仍然使用src/index.html
也为了serve
on "@angular/cli": "^8.3.6", "@angular/compiler-cli": "^8.2.8"
。看起来没有覆盖serve
本身。
我的问题是:should serve
总是继承基础index
配置?
尝试进一步挖掘,我发现了这一点:https://github.com/angular/angular-cli/issues/14599 https://github.com/angular/angular-cli/issues/14599
有一个示例说明它如何与新 CLI 一起工作,但尝试替换
"development": {
index": "index-whatever.html"
}
with a
"development": {
index": {
"input": "index-whatever.html"
}
}
和建筑,它给了我一个Schema validation failed with the following errors: Data path ".index" should be string.
===========
2020 年 4 月 10 日更新:
我刚刚注意到,在十月的更新中,我错过了最新代码片段中的引用。我不记得它是否是直接从我的代码复制的 - 因此报告的错误可能与此相关 - 或者当我尝试重写代码时这是一个错误。我一有时间就会再检查一次