在项目中引入clean-webpack-plugin打包后报错
new CleanWebpackPlugin(),
^
TypeError: CleanWebpackPlugin is not a constructor
const CleanWebpackPlugin = require(‘clean-webpack-plugin‘) plugins: [ new CleanWebpackPlugin(), new HtmlWebpackPlugin({ filename: ‘index.html‘, template: ‘./src/index.html‘ }) ],
看了一下githup上的写法,现在新版本的clean-webpack-plugin引入已经改为const
所以修改引入写法就OK了
const {CleanWebpackPlugin} = require(‘clean-webpack-plugin‘) plugins: [ new CleanWebpackPlugin(), new HtmlWebpackPlugin({ filename: ‘index.html‘, template: ‘./src/index.html‘ }) ],
TypeError: CleanWebpackPlugin is not a constructor
原文:https://www.cnblogs.com/steamed-twisted-roll/p/10990309.html