I
I
Incold2020-10-10 16:45:21
webpack
Incold, 2020-10-10 16:45:21

Why does the copy webpack plugin add **/* to the end of the path?

Hello! Trying to understand why the copy webpack plugin adds **/* to the end of the path and solve the unable to locate error accordingly
Here is the code:

new CopyWebpackPlugin({
      patterns: [
        { // Ругается именно на этот путь
          context: path.resolve(__dirname),
          from: 'src/assets/images',
          to: 'dist/images'
        },
        {
          context: path.resolve(__dirname),
          from: 'src/assets/favicon.ico',
          to: 'dist/favicon.ico'
        },
        {
          context: path.resolve(__dirname),
          from: 'web.config',
          to: 'dist/web.config'
        }
      ]
    })


I want to copy the entire folder, I checked that the paths I specified are correct, but webpack changes the path to "src/assets/images/**/*". The error comes out only when I try to copy the folder, it works fine with other paths.
How to fix it?
Thanks in advance for any help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AlekseyOgorodnikov, 2021-05-24
@AlekseyOgorodnikov

You need to add the noErrorOnMissing: true option, which will tell the collector if the folder is empty, then skip it and don't generate an error.
{
//Copy assets
from: path.resolve(__dirname, "./src/assets/images"),
to: path.resolve(__dirname, "./dist/images"),
noErrorOnMissing: true,
}
Your folder is empty simply.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question