1. 程式人生 > 實用技巧 >webpack中文網的錯誤&&未更新內容(webpack4)

webpack中文網的錯誤&&未更新內容(webpack4)

https://www.webpackjs.com/guides/

截止到2020/07/24還存在的錯誤

(一)(管理輸出部分)清理dist資料夾無用檔案的外掛:

clean-webpack-plugin

引用地址:https://www.jianshu.com/p/0e99366ce796

使用步驟:

cnpm install clean-webpack-plugin --save-dev

在webpack.config.js配置檔案中

const {CleanWebpackPlugin} = require('clean-webpack-plugin');
plugins: [
     new CleanWebpackPlugin()
... ],

(二)(程式碼分離部分)防止重複,將一些公用的外掛提取出來單獨打包:

引用地址:https://blog.csdn.net/github_36487770/article/details/80228147?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase

CommonsChunkPlugin

使用步驟:不需要cnpm安裝

在webpack.config.js配置檔案中

const webpack = require('webpack');
 optimization: {
    splitChunks: {
        cacheGroups: {
            commons: {
                name: "commons",
                chunks: "initial",
                minChunks: 2
            }
        }
    }
}

but,裡面各項引數變複雜了....