Today, I want to copy the pictures of the company’s projects to build / images,
Direct installation
npm install copy-webpack-plugin --save-dev
, using the latest official documentation
new CopyPlugin({
patterns: [
{ from: 'source', to: 'dest' },
{ from: 'other', to: 'public' },
],
}),
However, it is always reported that cannot read property ‘this compilation’ of undefined
The results show that the webpack is “^ 1.13.2” because the company’s projects are older,
So you can reduce the copy webpack plugin version to below 5.0.0, and then use the old writing method
For example, “copy webpack plugin”: “^ 4.6.0”,