{
"to": "assets",
"from": {
"glob": "src/assets/**/*",
"dot": true
}
}
this ends up creating "dist/assets/src/assets" instead of copying all sub-dirs/files from src/assets into assets/
Why would I end up with assets/src/assets if the glob pattern is all subdirectories/files inside src/assets?
Thanks
I have the same issue. Attaching my configuration below:
new CopyWebpackPlugin([{
"from": "src/assets/**/*.*",
"to": "assets",
"toType": "dir"
}], {
"ignore": [
".gitkeep"
],
"debug": "warning"
})
@nickenchev : The following configuration seemed to resolve the issue for me. This may help in your case as well:
{
"context": './src/assets/',
"from": '**/*',
"to": './assets/'
},
One caveat here is that my webpack config file is within a folder called 'webpack' and not at project root level, (the folder contains specific webpack files for different environments) so I have moved up a level in the hierarchy using the './' in the paths.
If your webpack config file is at the root level, you can simply use 'src/assets/' for the "context" parameter
@nickenchev @jcardoz plugin works as expected by default context (compiler.options.context - example /path/to/src), glob with default cwd options (compiler.options.context) return src/assets/file.txt.
Output directory /path/to/dist, to interpreted as /path/to/dist/assets/ + src/assets/file.txt. For resolve this issue see comment above. In short - use context option. Thank you!
Most helpful comment
@nickenchev : The following configuration seemed to resolve the issue for me. This may help in your case as well:
{ "context": './src/assets/', "from": '**/*', "to": './assets/' },One caveat here is that my webpack config file is within a folder called 'webpack' and not at project root level, (the folder contains specific webpack files for different environments) so I have moved up a level in the hierarchy using the './' in the paths.
If your webpack config file is at the root level, you can simply use 'src/assets/' for the "context" parameter