It would be expected the documented syntax for the plugin works.
If the constructor is structured like the documentation, you get an error like this:
CopyPlugin Invalid Options
options should be array
ValidationError: CopyPlugin Invalid Options
at validateOptions (C:\Users\user\code\app\node_modules\copy-webpack-plugin\node_modules\schema-utils\src\validateOptions.js:32:11)
Error-causing code:
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
plugins: [
new CopyPlugin({
patterns: [
{ from: 'source', to: 'dest' },
{ from: 'other', to: 'public' },
],
}),
],
};
Good code:
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
plugins: [
new CopyPlugin(
[
{ from: 'source', to: 'dest' },
{ from: 'other', to: 'public' },
]
),
],
};
Create webpack config with documented syntax.
Oh man this just tripped me up for the last hour or so. I was about to downgrade to try and get around this. Thanks!
I can confirm I am having this problem as well.
I see from the git history that you just made a breaking change that hasn't been released yet, but it's frustrating and time consuming that I'm working with a freshly installed module and reading the official docs, but it doesn't work as documented.
Perhaps release branches would reduce these issues.
We have a next branch in master because we prepare next release, please use documentation from here https://github.com/webpack-contrib/copy-webpack-plugin/tree/v5.1.1, release will be soon
I don't know why this issue was closed - I searched the open issues because of this problem an hour ago, but only found this solution now. The issue is not resolved until the incorrect public documentation has been fixed. Until then, people are going to be trying to understand why this is not working and looking through your open issues and not finding this.
This should absolutely not be closed.. This is clearly an issue and this ticket serves as a point of reference for people who have this problem. This should be closed once the change has been merged..
I think the OP had the wrong version, but it is happening on for me on version 5.1.1. I just spent way to much time with this problem.
I think the OP had the wrong version, but it is happening on for me on version 5.1.1. I just spent way to much time with this problem.
Sorry. That was a typo on my part. 5.1.1 is correct.
@evilebottnawi do you think you can mark v5.1.1 branch as default in GitHub for now, to prevent this kind of confusion?
Short answer:
new CopyWebpackPlugin([
{ from: 'source', to: 'dest' },
])
Long answer:
...please use documentation from here https://github.com/webpack-contrib/copy-webpack-plugin/tree/v5.1.1, release will be soon
I'm having the same issue. Please fix.
It's too much!!!,copy-webpack-plugin 5.1.1 is
new CopyPlugin([
{ from: '...', to: '...' },
])
README.md is
new CopyPlugin({
patterns: [
{ from: 'source', to: 'dest' },
{ from: 'other', to: 'public' },
],
})
Same problem =(
Same here.
Same here, documentation is confuse.
6 version was released https://github.com/webpack-contrib/copy-webpack-plugin/releases/tag/v6.0.0
https://webpack.js.org/plugins/copy-webpack-plugin/ is still showing the old syntax. gave up and googled. here I am. weird issue to have?
Most helpful comment
I don't know why this issue was closed - I searched the open issues because of this problem an hour ago, but only found this solution now. The issue is not resolved until the incorrect public documentation has been fixed. Until then, people are going to be trying to understand why this is not working and looking through your open issues and not finding this.