webpack4当webpack配置文件不在根目录时如何配置CleanWebpackPlugin?

新版clean-webpack-plugin在使用上一共两个变化。1.不需要指定打包文件名,他会自动找output下面的配置。2.引入时需要使用一个对象去接收
  • 目录展示

webpack4当webpack配置文件不在根目录时如何配置CleanWebpackPlugin?_第1张图片

  • 版本展示
// 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')
}

你可能感兴趣的:(webpack4)