The one you say, ng serve --configuration=production actually replaces environment.ts with environment.prod.ts. It is already defined in Angular.
In case you want to have another replacements (i.e., more files replaced) depending on configuration, go to you angular.json and follow the structure:
- Create a new configuration name under
build:configurations
- Fill in the
fileReplacements array with your files to be replaced
- Under
serve:configurations create a new tag, and reference to the one you just created.
- Launch serve, like:
ng serve --c=configuration-name (note that --c is the same as --configuration)
Example:
{
. . .
"projects": {
"your-project-name": {
. . .
"architect": {
"build": {
. . .
"options": { . . . },
"configurations": {
"production": { . . . },
"configuration-you-want-to-create": {
"fileReplacements": [
{
"replace": "src/path-to-file.original",
"with": "src/path-to-file.tobereplaced"
},
{
"replace": "src/other-path-to-file.original",
"with": "src/other-path-to-file.tobereplaced"
}
]
}
}
},
"serve": {
. . .
"options": {. . .},
"configurations": {
"production": { . . .},
"configuration-you-want-to-create": {
"browserTarget": "your-project-name:build:configuration-you-want-to-create"
}
}
},
. . .
}
}},
. . .
}