webpack-contrib/copy-webpack-plugin

Allow `from` to be array of paths / glob, respect order

emkayy opened this issue · 10 comments

Feature Proposal

Please allow the from property to contain an array of paths / glob patterns
because I need to include files from several different locations and copy them all into one folder.
This is quite ugly and verbose doing it with glob.

The assets array in transformAll should then be returned in the order of the from array so you can rely on javascript execution order.

Feature Use Case

Copying and or concatenating and transforming (javascript) files from multiple locations into one file / folder.

Please paste the results of npx webpack-cli info here, and mention other relevant information

not relevant

Respecting order is very bad for perf, work is going on on different cores, please sort them inside transformAll as you want, sorry, we don't want to implement this

Hi, I don't see how this would affect performance. The array is already getting sorted (

assets.sort((a, b) =>
)
Only the sorting logic would need te be changed so it does sort according to the input order.

Because this logic don't know nothing about of input order

Well, actually it does:


item does contain the from property and if from is an array, the sort method has access to the input order.

Try to implement this and PR welcome

I thought you are offering feature requests here?

I don't understand why you need order by patterns, your order already the same, what is point to do unnecessary calculations

This feature request basically consists of 2 parts:

1. from as an array

  • This would make copying from different locations to one destination a lot easier
  • Only an array enables the transformAll method to keep the output in the same order as the input

... which brings me to the 2nd part:

2. Ordering of the transformAll parameter assets

  • This is important for concatenating CSS and JS files, as both heavily rely on code order (CSS: overriding selectors, JS: execution order)

from as an array

Yes, we can do it, make sense, but why do not use blog base above and using filter function, better DX?

Anyway it is low priority, so PR welcome