Currently, there is only one option to overwrite the contents of a file, but none to merge the contents. Here it would make sense to offer a append option. If this is set to true, the files should be merged.
Here is an example of the expected result:
# file: ./default/phrases.txt
name: Name
markdown: Markdown
# file: ./production/phrases.txt
title: CopyWebpack
The result should be following (./dist/phrases.txt):
# file: ./default/phrases.txt
name: Name
markdown: Markdown
# file: ./production/phrases.txt
title: CopyWebpack
This feature has already been implemented by myself. You can find it in this fork:
https://github.com/kpalatzky/copy-webpack-plugin
If you are interested, you can do it yourself or I will prepare a pull request for you.
Could you keep an eye on https://github.com/webpack-contrib/copy-webpack-plugin/pull/103 which proposes a merge option for patterns ? Needs a rebase first though :). Feel free to open a PR proposing your implementation aswell of course 馃槢
I'd love to see this feature.
@michael-ciniawsky Is this dependent on #103? Or can this proceed regardless? It looks like such a simple change...
@markwoon Nope it doesn't, feel always free to open a PR
@kpalatzky Can you submit a PR, or would you be OK with me creating a PR based on your changes?
@markwoon PR welcome
@markwoon It would be great if you can create the PR, because i have currently no time for it. If you dont want do it, i can do it within the next weeks.
Is anybody actively working on this? I've found I have a need for this feature as well.
If not, I am happy to construct and submit the PR. I've tried @kpalatzky's fork, and I could bring in that logic and write some tests. I can do it tomorrow.
This plugins intent isn't to merge file contents, it copies files from point A to point B & loaders & plugins for the most part should do one thing.
If someone wants to create a plugin, technically another one as there are already a few feel free. If someone want to create one within contrib, feel free to contact me.
In either case, extending the API to handle merging / appending / stitching / truncating of file contents is functionality that is outside the scope of this plugin.
@d3viant0ne I think that if you often have the same from path you need more than one way to deal with it.
Most files are also copied, but files with the same name have to be merged here.
In our case we have multible plugins with the same file (core.css):
plugin1/css/core.css
plugin1/css/theme.css
plugin2/css/core.css
plugin3/css/core.css
And we are building one project out of these plugins:
all/css/core.css
all/css/theme.css
In this case you can copy the theme.css file, because it only exists once. But how do you want to handle the core.css file. To add an new webpack plugin which is only responsable for "mergin files" cant be used, because you do not know which files have to be merged and which not...
Therefore, the only reasonable reason is to add additional parameters is to this plugin.
@d3viant0ne @kkennis @markwoon Are there any updates on this?
This would be a great feature!
Now you can do it using the transformAll option https://github.com/webpack-contrib/copy-webpack-plugin/pull/596, release will be today
Most helpful comment
@d3viant0ne I think that if you often have the same from path you need more than one way to deal with it.
Most files are also copied, but files with the same name have to be merged here.
In our case we have multible plugins with the same file (
core.css):plugin1/css/core.cssplugin1/css/theme.cssplugin2/css/core.cssplugin3/css/core.cssAnd we are building one project out of these plugins:
all/css/core.cssall/css/theme.cssIn this case you can copy the
theme.cssfile, because it only exists once. But how do you want to handle thecore.cssfile. To add an new webpack plugin which is only responsable for "mergin files" cant be used, because you do not know which files have to be merged and which not...Therefore, the only reasonable reason is to add additional parameters is to this plugin.