Copying Files into Webpack
With Webpack, you can copy files from your project folder to your build folder. This is done using the following plugin: copy-webpack-plugin.
Let's install it:
terminalnpm install copy-webpack-plugin --save-dev
We import:
webpack.config.jsimport CopyPlugin from 'copy-webpack-plugin';
Let's copy, for example, a favicon using this plugin:
webpack.config.jsexport default {
entry: './src/index.js',
plugins: [
new CopyPlugin({
patterns: [
{
from: path.resolve('src/favicon.ico'),
to: path.resolve('dist')
},
],
}),
],
};
Задание 1
Install the plugin and make a copy of some file.
Задание 2
Check out the plugin documentation and learn how to make bulk copies of files.