I have two build configurations "production" and "development". By selecting one of the following two commands I can decide for which config I want to build the app:
ng build --configuration=developmentng build --configuration=production
And in the angular.json I specify the build options for each config:
"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"
}
],
.
.
.
}
}
},
Basically I change the environment.ts as well as the index.html according to the selected build config.
Is there a way to have two robots.txt files in the project folder, for instance robots.dev.txt and robots.prod.txt and conditionally add one of them as robots.txt to the dist folder during the build? Pretty much how I do it with the index file.
The purpose is to prevent all search engine robots from indexing my development build, but allow them to index the production build.