新版 clean-webpack-plugin 在使用上一共两个变化。1. 不需要指定打包文件名,他会自动找 output 下面的配置。2. 引入时需要使用一个对象去接收
- 目录展示
- 版本展示
// package.json
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11",
"clean-webpack-plugin": "^3.0.0",
- 导入
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
- 配置
// webpack.config.js
plugins: [new webpack.ProgressPlugin(),
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({template: 'index.html'})
],
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, '../dist')
}