I tried to do something like this:
plugins: [
new CopyWebpackPlugin([
{
from: 'a.js',
to: 'b.js',
},
{
from: 'a.js',
to: 'c.js',
},
]),
],
When doing that, only one output file is created.
I had to do this to make it work:
plugins: [
new CopyWebpackPlugin([
{
from: 'a.js',
to: 'b.js',
},
]),
new CopyWebpackPlugin([
{
from: 'a.js',
to: 'c.js',
},
]),
],
Yup — I have exactly the same problem
Me too. Are we doing something wrong? Are we supposed to new up that plugin for each copy?
That's exactly what I ended up doing. I'm assuming it's wrong!
I think i figured it out. Ran into the same issue with having to dupe across. It appears that in watch mode, when a file is encountered once, it is placed into a cache. I had to enable copyUnmodified in order to make it work:
new CopyWebpackPlugin([
// backwards compat
{ from: 'src/assets/images', to: 'css/images' },
{ from: 'src/assets/images', to: 'images' },
{ from: 'src/assets/fonts', to: 'css/fonts' },
{ from: 'src/assets', to: 'assets' },
{ from: 'src/meta'},
], {
copyUnmodified: true
}),
Fixex in https://github.com/webpack-contrib/copy-webpack-plugin/pull/165, please update to latest version. Also feel free to reopen issue if you still have problem.
Most helpful comment
I think i figured it out. Ran into the same issue with having to dupe across. It appears that in watch mode, when a file is encountered once, it is placed into a cache. I had to enable
copyUnmodifiedin order to make it work: