// 对于最新的webpack版本:4.35.2
// 在原教程中,抛错原写法
const CleanWebpackPlugin = require("clean-webpack-plugin");
...
plugins: [
new CleanWebpackPlugin(['dist'])
]
...
// 另一种错误写法
const CleanWebpackPlugin = require("clean-webpack-plugin");
...
plugins: [
new CleanWebpackPlugin(['dist'], {
root: path.resolve(__dirname, '../'), //根目录
})
]
...
// =============================分割线==============================
// 正确写法
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
...
plugins: [
new CleanWebpackPlugin()
]
...