Copy-webpack-plugin: [Bug] Copy multiple time the same file does one input only

Created on 22 Nov 2016  Â·  5Comments  Â·  Source: webpack-contrib/copy-webpack-plugin

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',
    },
  ]),
],
Bug

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 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
      }),

All 5 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amgohan picture amgohan  Â·  5Comments

gh67uyyghj picture gh67uyyghj  Â·  4Comments

alexprice1 picture alexprice1  Â·  5Comments

smashercosmo picture smashercosmo  Â·  6Comments

cletusw picture cletusw  Â·  5Comments