clean-webpack-plugin 3.0以上版报错,TypeError: CleanWebpackPlugin is not a constructor

/ 0评 / 2

使用 clean-webpack-plugin 插件后,在打包过程中,抛出 TypeError: CleanWebpackPlugin is not a constructor 的错误 

正确的写法:

const { CleanWebpackPlugin } = require('clean-webpack-plugin')
 
module.exports = {
    ...
    plugins: [
            new CleanWebpackPlugin()
    ]
}

新版的引用方式已改成 const { CleanWebpackPlugin } = require('clean-webpack-plugin');如果继续使用旧版引用方式,会报 “CleanWebpackPlugin is not a constructor ” 错误

发表评论

电子邮件地址不会被公开。 必填项已用*标注