Browse Source

build: optimize bundle size by updating split strategy

Aakansha Doshi 1 năm trước cách đây
mục cha
commit
43200a2844
1 tập tin đã thay đổi với 10 bổ sung2 xóa
  1. 10 2
      src/packages/excalidraw/webpack.prod.config.js

+ 10 - 2
src/packages/excalidraw/webpack.prod.config.js

@@ -89,11 +89,19 @@ module.exports = {
       }),
     ],
     splitChunks: {
-      chunks: "async",
+      chunks: "all",
       cacheGroups: {
         vendors: {
           test: /[\\/]node_modules[\\/]/,
-          name: "vendor",
+          // cacheGroupKey here is `commons` as the key of the cacheGroup
+          name(module, chunks, cacheGroupKey) {
+            const moduleFileName = module
+              .identifier()
+              .split("/")
+              .reduceRight((item) => item);
+            const allChunksNames = chunks.map((item) => item.name).join("~");
+            return `${cacheGroupKey}-${allChunksNames}-${moduleFileName}`;
+          },
         },
       },
     },