Default to array prepend?
See original GitHub issueIn Webpack plugin order is significant. This means the first matched plugin wins. Currently webpack-merge concatenates arrays in the order it finds them. So if you have merge(common, prod), it will pick up plugins from common first and prod after that.
This can be problematic if you are trying to apply a plugin like DedupePlugin at prod as it would have to be before other plugins.
Maybe we should reverse this order? So that instead of appending, we would prepend arrays. That way the last merged array would win and it would become easier to control ordering like this.
Any thoughts? Can you see any problems with this change? It would be a major version bump in any case.
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
javascript - Most efficient way to prepend a value to an array
to take advantage of the Array unshift(...) method: function prepend(value, array) { var newArray = array.slice(); newArray.unshift(value); ...
Read more >array.prepend() - Lucee Documentation
Inserts an array element at the beginning of an array and shifts the positions of the existing elements to make room. array.prepend( value=any,...
Read more >Array.prototype.fill() - JavaScript - MDN Web Docs - Mozilla
The fill() method changes all elements in an array to a static value, from a start index (default 0) to an end index...
Read more >zsh - How do I prepend a string to every element of an array?
Or to make that kind of expansion the default (in the style of rc or fish ): set -o rcexpandparam ARRAY=(my_$ARRAY).
Read more >JavaScript Add to an Array – JS Append - freeCodeCamp
By default, you can use the index of an element in an array to access or modify its value. But JavaScript provides different...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Given that webpack-merge is specifically targetted at webpack configs, could you change the merge strategy based on the property path being merged to do the thing that’s most likely to be right by default for a webpack config?
So for a top-level
pluginsprop, that could be prepending.Would it also be possible to allow users to override that in case it isn’t what they want?
@tleunen I added
merge.smartStrategy({ entry: 'module.loaders' })in0.18.0. That should give you more control over individual fields.merge.strategysupports nested fields now as well.