问题
Using CopyWebpackPlugin, I am not able to ignore a specific folder or a specific file. It copies everything.
What I have done in the webpack.config.js:
new CopyWebpackPlugin([
{
from: 'src/assets',
to: 'assets',
ignore: ['src/assets/img/folder/test.png']
},
]),
I also tried like that:
new CopyWebpackPlugin([
{
from: 'src/assets',
to: 'assets',
ignore: ['src/assets/img/folder/*']
},
]),
Regarding the readme I think I am doing right.
回答1:
Try this:
ignore: ['img/folder/**/*']
This will not copy the entire img/folder
.
Remember to clear your destination folder before running your webpack.
回答2:
New versions of CopyWebpackPlugin have changed the way of ignoring files.
new CopyWebpackPlugin({
patterns: [{
from: defaultSourcePath,
globOptions: {
ignore: [
'**/css/my.css',
'**/js/my.js',
'**/index.html'
]
}
}]
})
来源:https://stackoverflow.com/questions/56670264/copywebpackplugin-ignore-a-folder