webpack清理插件错误——TypeError: CleanWebpackPlugin is not a constructor
Error: clean-webpack-plugin only accepts an options object.
TypeError: CleanWebpackPlugin is not a constructor
以上两个错误属于同一个
之前这样写的:
const CleanWebpackPlugin = require("clean-webpack-plugin"); plugins:[ new CleanWebpackPlugin(['dist']), ]
然后报错:TypeError: CleanWebpackPlugin is not a constructor
后来这样写:
const {CleanWebpackPlugin} = require("clean-webpack-plugin"); plugins:[ new CleanWebpackPlugin(['dist']), ]
继续报错:Error: clean-webpack-plugin only accepts an options object.
最后这样写:
const {CleanWebpackPlugin} = require("clean-webpack-plugin"); plugins:[ new CleanWebpackPlugin(), ]
成功运行~
两点:
1、new CleanWebpackPlugin()中不能写参数,
2、需要用{}