CleanWebpackPlugin is not a constructor

当我们引入clean-webpack-plugin时,在WebPack构建生成的过程中可能会遇到如下报错:

TypeError: CleanWebpackPlugin is not a constructor

原因是改插件的引用方式改变了,由原来的的方式:

const CleanWebpackPlugin  = require('clean-webpack-plugin');

 plugins:[new CleanWebpackPlugin(['dist'])]

变成了现在的方式:

const { CleanWebpackPlugin }  = require('clean-webpack-plugin');

plugins:[new CleanWebpackPlugin()]
posted @ 2020-09-22 16:49  这是个坑  阅读(1186)  评论(0编辑  收藏  举报