Repository navigation
Mixing configurations #10612
Copy link
Copy link
Closed
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: @angular-devkit/architectarea: @angular/clifeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issues
Milestone
Description
Versions
v6
Observed behavior
You cannot use --prod with a custom configuration since --prod is an alias for --configuration=production. This means that if I make a custom configuration for my project, I need to duplicate it for the prod build to include everything from the production configuration.
Desired behavior
I'd like to be able to mix configurations, where each one overwrites the precedent. For example with -c=prod,xxx, where xxx overwrites production values if they both define the same property
For example if I'm doing i18n, I would like to have something like that:
"configurations": {
"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
},
"fr": {
"aot": true,
"outputPath": "dist/my-project-fr/",
"i18nFile": "src/locale/messages.fr.xlf",
"i18nFormat": "xlf",
"i18nLocale": "fr",
"i18nMissingTranslation": "error"
}
}
},
And use -c=production,fr, or --prod -c=fr
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: @angular-devkit/architectarea: @angular/clifeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issues
Activity
filipesilva commentedon May 3, 2018
@buu700 was also interested in something similar in #10559
phl3x0r commentedon May 4, 2018
That would be a great addition.
At the moment (in the 1.x.x config) I have a setup with many apps sharing a lot of the same (duplicate) configuration. I was hoping that 6.0 would provide a way to share common configuration between app flavors, but at this point, the config will just be even more bloated than before.
In my case it's not the i18n files (although potentially it will be in the future), but assets, styles and environment files that changes between customers (apps).
MickL commentedon Jun 14, 2018
Alternative to using multiple configurations they could have a extend feature as mentioned here: #11233 . Definitely need either one of them.
MickL commentedon Jun 14, 2018
@hansl Personally i would set this issue to priority 2 (required). Instead of:
ng build -c=prod,theme1,enandng serve -c=theme1,enwe have to make TONS configurations with TONS of duplicate code:
And this was just 2 themes and 2 languages. It multiplies for each other theme or language...
phl3x0r commentedon Jun 16, 2018
Looks like our situation. 30+ configurations x 6 different environments = wall of config
rmsmq commentedon Jul 27, 2018
Unless I am misunderstanding, I don't think this will reduce the number of configurations, only duplication within the configurations.
I would prefer the proposed solution in this issue, which should allow for significantly less configurations.
paulheising commentedon Aug 16, 2018
+1
would definitely need such a feature!
PhoneixS commentedon Sep 26, 2018
I think that it should be mentioned in the documentation in Deployment because nowadays it is in i18n:
robertjk commentedon Oct 1, 2018
I also think this feature is essential to write maintainable, clean configurations, especially when you implement internationalization.
I wonder if this problem could also be solved by allowing
angular.jsonto be written in YAML (angular.yaml), as YAML lets you declare anchors to duplicate properties.wulfsberg commentedon Oct 6, 2018
I agree with @MickL that this is beyond a "nice to have". Even something as trivial as changing the default locale (for pipes) explodes into a barrage of cut'n'paste all over the already-not-too-friendly
angular.json.splincode commentedon Dec 26, 2018
@mgechev it would be cool to be able to inherit
phl3x0r commentedon Jan 4, 2019
I think this issue needs more attention.
Our angular.json file is currently 14048 lines and growing, not even counting the multitude of i18n configurations that are yet to be implemented.
13 remaining items
abariatti commentedon Aug 12, 2019
@asvishnyakov Would you have the awesomness of providing a running gist?
asvishnyakov commentedon Aug 18, 2019
@abariatti I cannot show you full code because of my contract limitations, but the idea is simple.
Add
angular.tsand put your current json to it as typescript object, i.e.Then add output to the angular.json:
Now, in
packages.jsonadd tasks to compile and run it:{ "scripts": { "angular-json:build": "tsc --moduleResolution node --lib es2018 --outFile angular.js angular.ts", "angular-json:transform": "npm run angular-json:build && node angular.js",Then run
angular-json:transformtask manually every time you changeangular.tsor add it before every build or run task inpackages.json:{ "scripts": { "build": "npm run angular-json:transform && ng build"feat(@angular/cli): support using multiple configurations
feat(@angular/cli): support using multiple configurations
feat(@angular/cli): support using multiple configurations
feat(@angular/cli): support using multiple configurations
feat(@angular/cli): support using multiple configurations
feat(@angular/cli): support using multiple configurations
feat(@angular/cli): support using multiple configurations
angular-automatic-lock-bot commentedon Nov 14, 2019
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.
feat(@angular/cli): support using multiple configurations