webpack優化

1,增長CleanWebpackPlugin插件,做用是,清空以前的dist文件夾,避免文件積攢babel

2,因爲開發模式下會運行 HotModuleReplacementPlugin
因此在本地build的時,會針對生成的新的dist文件,這樣就觸發了熱更新並自動運行babel-loader,而babel-loader會生成新的轉碼文件,會使得dist文件夾下面增長沒必要要的轉碼文件。
此時須要在babel-loader裏面增長exclude字段,再也不轉碼dist文件夾ui

{
        test: /\.js$/,
        loader: 'babel-loader',
        include: [resolve('src'), resolve('test')],
        exclude: /dist/, // 再也不轉碼dist文件夾
        options: {
          cacheDirectory:true
        }
      },
相關文章
相關標籤/搜索