CleanWebpackPlugin is not a constructor

今天在自行配置 webpack.config.js 文件时报了这样的错:TypeError: CleanWebpackPlugin is not a constructor
之后去官方文档看了看,发现是用法变了
以前引入是这样的:

const HtmlWebpackPlugin = require("html-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");

现在应该这样引入:

const HtmlWebpackPlugin = require("html-webpack-plugin");
const {CleanWebpackPlugin} = require("clean-webpack-plugin");

总结:加一个花括号引入就可以了,其他不变

你可能感兴趣的:(CleanWebpackPlugin is not a constructor)