question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default to array prepend?

See original GitHub issue

In 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:closed
  • Created 7 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
insincommented, May 10, 2016

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 plugins prop, that could be prepending.

Would it also be possible to allow users to override that in case it isn’t what they want?

let mySpecialMerge = merge.strategy({plugins: 'append'})
1reaction
bebrawcommented, Nov 24, 2016

@tleunen I added merge.smartStrategy({ entry: 'module.loaders' }) in 0.18.0. That should give you more control over individual fields. merge.strategy supports nested fields now as well.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found