Error: clean-webpack-plugin only accepts an options object.webpack
TypeError: CleanWebpackPlugin is not a constructorweb
以上两个错误属于同一个ui
以前这样写的:spa
const CleanWebpackPlugin = require("clean-webpack-plugin"); plugins:[ new CleanWebpackPlugin(['dist']), ]
而后报错:TypeError: CleanWebpackPlugin is not a constructorcode
后来这样写:blog
const {CleanWebpackPlugin} = require("clean-webpack-plugin"); plugins:[ new CleanWebpackPlugin(['dist']), ]
继续报错:Error: clean-webpack-plugin only accepts an options object.io
最后这样写:class
const {CleanWebpackPlugin} = require("clean-webpack-plugin"); plugins:[ new CleanWebpackPlugin(), ]
成功运行~require
两点:object
一、new CleanWebpackPlugin()中不能写参数,二、须要用{}