⊗tlWpPlBDC 54 of 55 menu

Cleaning up the build folder in Webpack

By default, Webpack places new files in the build folder without deleting the previous ones. This is a bit inconvenient. The following plugin will help you clean the folder: clean-webpack-plugin.

Let's install it:

npm install clean-webpack-plugin --save-dev

We import:

import {CleanWebpackPlugin} from 'clean-webpack-plugin';

Let's turn on:

export default { entry: { test1: './src/test1.js', test2: './src/test2.js', test3: './src/test3.js', }, output: { filename: '[name].[contenthash].js', path: path.resolve('dist'), // required for the plugin to work }, plugins: [ new CleanWebpackPlugin(), ], };

Install this plugin and check its operation.

enru