1,增加CleanWebpackPlugin插件,作用是,清空之前的dist文件夾,避免文件積攢
2,由於開發模式下會運行 HotModuleReplacementPlugin
所以在本地build的時,會針對生成的新的dist文件,這樣就觸發了熱更新並自動運行babel-loader,而babel-loader會生成新的轉碼文件,會使得dist文件夾下面增加不必要的轉碼文件。
此時需要在babel-loader裏面增加exclude字段,不再轉碼dist文件夾
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('test')],
exclude: /dist/, // 不再轉碼dist文件夾
options: {
cacheDirectory:true
}
},