webpack.config.js中配置:
// 导入插件,自动请理dist目录下的旧文件
const {CleanWebpackPlugin} = require ('clean-webpack-plugin')
const cleanPlugin = new CleanWebpackPlugin()
// 插件的数组,将来webpack再运行时,会加载并调用这些插件
plugins: [htmlPlugin,cleanPlugin],
cmd中安装:
npm i clean-webpack-plugin@3.0.0 -D