-
Notifications
You must be signed in to change notification settings - Fork 12k
File replacements for multiple configs are not getting merged #16688
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
It is indeed intentional that multiple configurations are not deeply merged. We opted for that approach for now because deep merging doesn't allow for wholly replacing objects easily, while shallow merging does. So while there is repetition, the mental model is straightforward and isn't missing capabilities. We might provide more merge strategies in the future, but it just didn't make a lot of sense to start with the least flexible one. |
@filipesilva thanks. How would you suggest to address the usecase I am depicting? Would I have to create the permutations "production-edit", "production-view", "normal-edit", "normal-view" to capture the correct replacements? |
There's no great way of doing it that doesn't involve repetition at the moment. So something like that would be the best approach currently. |
I'd love a feature where I'd be able to merge the fileReplacements-Array for example. If I have to copy/paste the build config permutations, the angular.json file gets quite big for me... Best approach for me would be to merge the fileReplacements-Arrays together, like: So when ng build --configuration a,b is run it uses: Instead of only using fileReplacements for config b: |
I am also interested in having a way to extend configurations (fileReplacements) instead of overriding it. will save us a lot of repetition in |
Hi, I had read this feature enhancement as each subsequent configuration in the comma delimited list being merged into the target, thus overwriting any properties along the way. We're talking about shallow vs deep copies here, but I've got a set of shallow object graphs with simple properties that aren't being merged at all - just taking the last item and overwriting environment.ts wholesale. Looking at the PR that made the change it looks like we're just applying the last iteration of configurations instead of merging, right? I'm missing something I think. What version of the CLI is in this in? I'm using 9; and it's in the docs there, but I don't see any tags or anything indicating where the change went upon merge to master. |
Duplicate of #11149 |
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. |
🐞 Bug report
Command (mark with an
x
)Is this a regression?
no
Description
With #15819 the CLI allows to define multiple configurations that get overlayed. However the merge process of the configs only does a shallow merge, which e.g. for
fileReplacements
means that all replacements in a previous config get overriden.I suggest to do a deep merge on the configurations, not a shallow merge.
🔬 Minimal Reproduction
Example:
with this
angular.json
:I specify two new configs
edit
andview
. These configs are logically orthogonal to production vs normal mode, so I would like to be able to build the application e.g. like this:ng build --configuration=edit
and
ng build --configuration=production,edit
However the later does not work as expected because the file replacements for the environment as defined in the
production
config are overridden.🌍 Your Environment
Anything else relevant?
The text was updated successfully, but these errors were encountered: