How to avoid duplication in configuration?
I am using Angular version 9 using nx workspace. I have 5 different projects along with 11 different configurations per project.
How can I eliminate the reusable configurations like aot:true

You can achieve this by providing multiple configurations.
"configurations": {
"feature": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.feature.ts"
}
],
},
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
}
}
Example ng build --configuration=production,feature
See: https://angular.io/guide/workspace-config#alternate-build-configurations
You can achieve this by providing multiple configurations.
"configurations": { "feature": { "fileReplacements": [ { "replace": "src/environments/environment.ts", "with": "src/environments/environment.feature.ts" } ], }, "production": { "fileReplacements": [ { "replace": "src/environments/environment.ts", "with": "src/environments/environment.prod.ts" } ], "optimization": true, "outputHashing": "all", "sourceMap": false, "extractCss": true, "namedChunks": false, "aot": true, "extractLicenses": true, "vendorChunk": false, "buildOptimizer": true } }Example
ng build --configuration=production,featureSee: https://angular.io/guide/workspace-config#alternate-build-configurations
Thanks for your response.
What I asked is how to eliminate
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
In all the configuration. Since I have more that 5 production deployments.
Hi @shabinpshams, as shown in the above example.
By listing common options in configuration namedproduction in this case and overridden options in another configuration named feature.
Then provide multiple comma-separated configurations in the configuration CLI option.
Ex:
ng build --configuration=production,feature
ng build --configuration=production,feature-foo
The command parses the named configurations from left to right. If multiple configurations change the same setting, the last-set value is the final one.
Hi @shabinpshams, as shown in the above example.
By listing common options in configuration named
productionin this case and overridden options in another configuration namedfeature.Then provide multiple comma-separated configurations in the
configurationCLI option.Ex:
ng build --configuration=production,feature ng build --configuration=production,feature-fooThe command parses the named configurations from left to right. If multiple configurations change the same setting, the last-set value is the final one.
Thanks again
But it showing error like

And I am using ngx-build-plus to build.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.