TypeError: CleanWebpackPlugin is not a constructor:https://www.cnblogs.com/steamed-twisted-roll/p/10990309.html
cleanWebpackplugin 升级踩坑:http://www.imooc.com/article/289614
https://www.jianshu.com/p/0e99366ce796
在项目中引入clean-webpack-plugin打包后报错
new CleanWebpackPlugin(),
^
TypeError: CleanWebpackPlugin is not a constructor
项目写法:
引入: cnpm i clean-webpack-plugin -D
webpack.config.js中
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' }) ],