From 43200a2844771c5210ecae29e3a36a6de5dd3b1b Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Tue, 5 Sep 2023 08:47:27 +0530 Subject: [PATCH] build: optimize bundle size by updating split strategy --- src/packages/excalidraw/webpack.prod.config.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/packages/excalidraw/webpack.prod.config.js b/src/packages/excalidraw/webpack.prod.config.js index 8f8c72eef..6203f066a 100644 --- a/src/packages/excalidraw/webpack.prod.config.js +++ b/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}`; + }, }, }, },