Webpack4.0报错clean-webpack-plugin only accepts an options object

官方文档中关于清理程序的示例 

const path = require('path');
  const HtmlWebpackPlugin = require('html-webpack-plugin');
+ const CleanWebpackPlugin = require('clean-webpack-plugin');

  module.exports = {
    entry: {
      app: './src/index.js',
      print: './src/print.js'
    },
    plugins: [
+     new CleanWebpackPlugin(['dist']),
      new HtmlWebpackPlugin({
        title: 'Output Management'
      })
    ],
    output: {
      filename: '[name].bundle.js',
      path: path.resolve(__dirname, 'dist')
    }
  };

 打包时会报错clean-webpack-plugin only accepts an options object

改为

new CleanWebpackPlugin(),问题解决,github上的https://github.com/johnagan/clean-webpack-plugin#options-and-defaults-optional 介绍了用法

你可能感兴趣的:(Webpack4.0报错clean-webpack-plugin only accepts an options object)