【webpack】踩坑:clean-webpack-plugin 插件使用问题

Webpack 官方指南踩坑:clean-webpack-plugin 配置问题

官方指南(版本:v4.39.1)

错误信息

TypeError: CleanWebpackPlugin is not a constructor

官方指南中的错误配置

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

module.exports = {
    plugins: [
        new CleanWebpackPlugin(['dist'])
    ]
};

正确配置

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

module.exports = {
    plugins: [
        new CleanWebpackPlugin()
    ]
};

关于 CleanWebpackPlugin() 中参数具体信息请参见 官方文档

你可能感兴趣的:(郝文档)