webpack报错:' CleanWebpackPlugin is not a constructor'
2021-01-20 03:13
标签:class https after 对象 赋值 not hub ons exp 原来是这么写的,但是报错了! 在官方 npm 找到了答案。 (1) 引入时要加上花括号(解构赋值) webpack报错:' CleanWebpackPlugin is not a constructor' 标签:class https after 对象 赋值 not hub ons exp 原文地址:https://www.cnblogs.com/buildnewhomeland/p/13328488.html问题
const CleanWebpackPlugin = require(‘clean-webpack-plugin‘);
module.exports = {
plugins: [
new CleanWebpackPlugin([‘dist‘]) // 打包之前,会将dist文件夹中的所有内容删除
]
}
解决
https://github.com/johnagan/clean-webpack-plugin#options-and-defaults-optionalconst { CleanWebpackPlugin } = require(‘clean-webpack-plugin‘);
module.exports = {
plugins: [
new CleanWebpackPlugin({
cleanAfterEveryBuildPatterns: [‘dist‘],
}) // 打包之前,会将dist文件夹中的所有内容删除
]
}
(2) 实例化对象时参数是一个对象,里面放option。
文章标题:webpack报错:' CleanWebpackPlugin is not a constructor'
文章链接:http://soscw.com/index.php/essay/44354.html