这个错误是使用webpack的一个plugin出现的错误。

这个plugin是​​copy-webpack-plugin​

我把文档的例子复制,然后就报了这个错误。

文档的例子:

const CopyPlugin = require("copy-webpack-plugin");

module.exports = {
plugins: [
new CopyPlugin({
patterns: [
{ from: "source", to: "dest" },
{ from: "other", to: "public" },
],
options: {
concurrency: 100,
},
}),
],
};

这个错误说的是这个CopyPlugin构造函数接收到的参数不合法,它需要传入一个​​array​​。

plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
template: "./public/index.html",
chunks: ["main"]
}),
new CopyPlugin([{
from: "./public/img",
to: "./img"
}]),
]