webpack SplitChunksPlugin 配置參數

//https://www.webpackjs.com/plugins/split-chunks-plugin/// 代碼分割splitChunks: {
    chunks: "all",  // async: 打包異步引入的代碼塊   all:  同步、異步   initial: 同步代碼
    minSize: 30000, // 字節  超出30kb的代碼塊 
    minChunks: 1,   // 模塊被使用次數
    maxAsyncRequests: 5, // 同時加載的模塊數 最多打包出的個數
    maxInitialRequests: 3, // 首頁 或 入口處
    automaticNameDelimiter: '~',    // 
    name: true,
    cacheGroups: { // 緩存組
        vendors: {  // vendors: false  打包的文件名再也不添加vendors
            test: /[\\/]node_modules[\\/]/,    // 匹配規則
            priority: -10,                      // 優先級       filename: 'vendors.js'
        },
      default: {   // default: false   
            minChunks: 2,
            priority: -20,
            reuseExistingChunk: true, //  一個模塊被打包過,不會重複打包       filename: 'common.js'
        }
    }
}
相關文章
相關標籤/搜索