⊗tlWpPlCF 55 of 55 menu

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:

npm install copy-webpack-plugin --save-dev

We import:

import CopyPlugin from 'copy-webpack-plugin';

Let's copy, for example, a favicon using this plugin:

export default { entry: './src/index.js', plugins: [ new CopyPlugin({ patterns: [ { from: path.resolve('src/favicon.ico'), to: path.resolve('dist') }, ], }), ], };

Install the plugin and make a copy of some file.

Check out the plugin documentation and learn how to make bulk copies of files.

enru