-
Notifications
You must be signed in to change notification settings - Fork 12k
Mixing configurations #10612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
That would be a great addition. |
Alternative to using multiple configurations they could have a extend feature as mentioned here: #11233 . Definitely need either one of them. |
@hansl Personally i would set this issue to priority 2 (required). Instead of:
we 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... |
Looks like our situation. 30+ configurations x 6 different environments = wall of config |
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. |
+1 would definitely need such a feature! |
I think that it should be mentioned in the documentation in Deployment because nowadays it is in i18n:
|
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 |
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 |
@mgechev it would be cool to be able to inherit "build": {
...
"configurations": {
"production": {
(...)
},
"pl": {
"extends": "config/pl.angular.json",
(...)
},
"en": {
"extends": "config/en.angular.json",
(...)
}
}
} |
I think this issue needs more attention. |
Any news on that? I have a workspace with many libraries and I have to duplicate test configs and other similar stuff for all of them. |
we are facing the same problem. for the time being is there any workaround/best practice to avoid copy and paste a great amount of the same configuration parts that someone could share? thank's a lot in advance |
I'd like to throw my hat in support of the solution proposed in #11233 where we have the ability to extend configs/use base configs in angular.json (rather than on the command line as suggested here). Since that issue was closed in favor of this one, I'm commenting here. This functionality would be so convenient for nx projects that may contain hundreds of libs all requiring the exact same configuration (e.g. for tests). @filipesilva, please let us make this happen. |
As a workaround I store angular.json as javascript object in angular.ts script. It allow me to store production configuration in single constant and reuse it with typescript spread syntax, i.e. configurations: {
production: ...productionConfiguration(),
anotherProductionConfiguration: {
...productionConfiguration(myParams),
otherProperty: 'value'
}
} I compile it and run as |
This feature would also solve the current issue that you can't use a global assets definition in options together with a build-specific assets definition. I assumed the assets in options would always be loaded, however they are ignored in case there is an assets array in your build configuration "options": {
// will only load for production, not for integration
"assets": [
{
"output": "assets",
"glob": "**/*",
"input": "src/assets"
}
]
},
"configurations": {
"integration": {
"assets": [
{
"output": "json",
"glob": "someFile.json",
"input": "src/json"
}
]
},
"production": {}
} |
I personally think that angular.json should be a angular.js that exports an object. I noticed this was requested here: #12943 This means we can do what @ashasvishnyakov described:
|
@asvishnyakov Would you have the awesomness of providing a running gist? |
@abariatti I cannot show you full code because of my contract limitations, but the idea is simple. Add const angularJson = { ... }; Then add output to the angular.json: const fs = require('fs');
const angularJson = { ... };
fs.writeFileSync('angular.json', JSON.stringify(angularJson, null, 4), 'utf8'); Now, in {
"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 {
"scripts": {
"build": "npm run angular-json:transform && ng build" |
It's now possible to use multiple configurations by separating them with a comma: ``` ng build --configuration=one,two,three ``` They will be applied from left to right. If `--prod` is also present, it will be considered to be the first configuration and thus able to be overriden. You can also use it in target strings: ``` "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { "browserTarget": "latest-project:build:one,two" }, "configurations": { "production": { "browserTarget": "latest-project:build:production,one,two" } } ``` Fix angular#10612
It's now possible to use multiple configurations by separating them with a comma: ``` ng build --configuration=one,two,three ``` They will be applied from left to right. If `--prod` is also present, it will be considered to be the first configuration and thus able to be overriden. You can also use it in target strings: ``` "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { "browserTarget": "latest-project:build:one,two" }, "configurations": { "production": { "browserTarget": "latest-project:build:production,one,two" } } ``` Fix angular#10612
It's now possible to use multiple configurations by separating them with a comma: ``` ng build --configuration=one,two,three ``` They will be applied from left to right. If `--prod` is also present, it will be considered to be the first configuration and thus able to be overriden. You can also use it in target strings: ``` "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { "browserTarget": "latest-project:build:one,two" }, "configurations": { "production": { "browserTarget": "latest-project:build:production,one,two" } } ``` Fix angular#10612
It's now possible to use multiple configurations by separating them with a comma: ``` ng build --configuration=one,two,three ``` They will be applied from left to right. If `--prod` is also present, it will be considered to be the first configuration and thus able to be overriden. You can also use it in target strings: ``` "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { "browserTarget": "latest-project:build:one,two" }, "configurations": { "production": { "browserTarget": "latest-project:build:production,one,two" } } ``` Fix angular#10612
It's now possible to use multiple configurations by separating them with a comma: ``` ng build --configuration=one,two,three ``` They will be applied from left to right. If `--prod` is also present, it will be considered to be the first configuration and thus able to be overriden. You can also use it in target strings: ``` "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { "browserTarget": "latest-project:build:one,two" }, "configurations": { "production": { "browserTarget": "latest-project:build:production,one,two" } } ``` Fix angular#10612
It's now possible to use multiple configurations by separating them with a comma: ``` ng build --configuration=one,two,three ``` They will be applied from left to right. If `--prod` is also present, it will be considered to be the first configuration and thus able to be overriden. You can also use it in target strings: ``` "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { "browserTarget": "latest-project:build:one,two" }, "configurations": { "production": { "browserTarget": "latest-project:build:production,one,two" } } ``` Fix angular#10612
It's now possible to use multiple configurations by separating them with a comma: ``` ng build --configuration=one,two,three ``` They will be applied from left to right. If `--prod` is also present, it will be considered to be the first configuration and thus able to be overriden. You can also use it in target strings: ``` "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { "browserTarget": "latest-project:build:one,two" }, "configurations": { "production": { "browserTarget": "latest-project:build:production,one,two" } } ``` Fix #10612
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Versions
v6
Observed behavior
You cannot use
--prod
with a customconfiguration
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 theproduction
configuration.Desired behavior
I'd like to be able to mix configurations, where each one overwrites the precedent. For example with
-c=prod,xxx
, wherexxx
overwritesproduction
values if they both define the same propertyFor example if I'm doing i18n, I would like to have something like that:
And use
-c=production,fr
, or--prod -c=fr
The text was updated successfully, but these errors were encountered: