【发布时间】:2020-12-01 10:02:42
【问题描述】:
我有两个构建配置“生产”和“开发”。通过选择以下两个命令之一,我可以决定要为哪个配置构建应用程序:
ng build --configuration=developmentng build --configuration=production
在angular.json 中,我为每个配置指定了构建选项:
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
.
.
.
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"index": {
"input": "src/index.prod.html",
"output": "index.html"
},
.
.
.
},
"development": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.dev.ts"
}
],
.
.
.
}
}
},
基本上我会根据选择的构建配置更改environment.ts 和index.html。
有没有办法在项目文件夹中有两个 robots.txt 文件,例如 robots.dev.txt 和 robots.prod.txt 并在构建期间有条件地将其中一个作为 robots.txt 添加到 dist 文件夹?几乎我如何使用索引文件来做到这一点。
目的是防止所有搜索引擎机器人索引我的开发版本,但允许它们索引生产版本。
【问题讨论】:
标签: angular