码迷,mamicode.com
首页 > Web开发 > 详细

使用CleanWebpackPlugin插件报错原因:CleanWebpackPlugin is not a constructor

时间:2019-11-10 15:40:26      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:color   clean   bpa   错误   分割   ack   res   ===   pre   

 1 // webpack版本:4.32.2
 2  
 3 // 抛错原写法
 4 const CleanWebpackPlugin = require("clean-webpack-plugin");
 5  
 6 ...
 7  
 8 plugins: [
 9     new CleanWebpackPlugin([‘dist‘])
10 ]
11  
12 ...
13  
14 // 另一种错误写法
15  
16 const CleanWebpackPlugin = require("clean-webpack-plugin");
17  
18 ...
19  
20 plugins: [
21     new CleanWebpackPlugin([‘dist‘], {
22         root: path.resolve(__dirname, ‘../‘),   //根目录
23     })
24 ]
25  
26 ...
27  
28 // =============================分割线==============================
29  
30 // 正确写法
31  
32 const { CleanWebpackPlugin } = require("clean-webpack-plugin");
33  
34 ...
35  
36 plugins: [
37     new CleanWebpackPlugin()
38 ]
39  
40 ...

 

使用CleanWebpackPlugin插件报错原因:CleanWebpackPlugin is not a constructor

标签:color   clean   bpa   错误   分割   ack   res   ===   pre   

原文地址:https://www.cnblogs.com/nayek/p/11830153.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!