1、安装clean-webpack-plugin插件
npm install clean-webpack-plugin --D
2、在webpack.dev.conf.js或者webpack.config.js下引入该模块, 并在plugins中进行配置
//引入模块 const cleanWebpackPlugin = require('clean-webpack-plugin'); //在plugins中进行配置 plugins: [ new cleanWebpackPlugin(['dist']) //清理dist文件夹 ]
3、重启项目即可