Using Webpack and copy-webpack-plugin I need to copy an entire folder during build and I have:
plugins: [
new CopyPlugin({
patterns: [
{ from: './src/assets', to: './assets' }
]
})
]
However this fails when the assets
folder is empty:
ERROR: unable to locate ...
If I add one file to assets folder i will work.
How to solve this?
Just add the property noErrorOnMissing to the patterns first object and set it to true. From what I understood, this will avoid generating an error if no file is present in the "from" destination folder, but at the same time it wont add the empty folder to your output folder (at least in my own test). This is the extract from one of my projects:
new CopyWebpackPlugin({
patterns: [
{
from: __dirname + '/src/assets/images',
to: 'assets/images',
noErrorOnMissing: true
}
]
})
Source: https://webpack.js.org/plugins/copy-webpack-plugin/#noerroronmissing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With