From 751c2fce3108ee0220d1774183bf75c41caf5df6 Mon Sep 17 00:00:00 2001 From: hazre Date: Sun, 8 Mar 2026 11:57:26 +0100 Subject: [PATCH] fix(build): allow PWA build with large wasm assets and split vendor chunks --- vite.config.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index 78e49451a..883def3a7 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -181,13 +181,26 @@ export default defineConfig({ VitePWA({ srcDir: 'src', filename: 'sw.ts', - strategies: 'generateSW', + strategies: 'injectManifest', injectRegister: false, manifest: false, + injectManifest: { + injectionPoint: undefined, + }, devOptions: { enabled: true, type: 'module', }, + workbox: { + maximumFileSizeToCacheInBytes: 10 * 1024 * 1024, // 10 MB + globIgnores: [ + '**/matrix_sdk_crypto_wasm_bg-*.wasm', + '**/vision_wasm_internal-*.wasm', + '**/qcms_bg.wasm', + '**/openjpeg.wasm', + '**/jbig2.wasm', + ], + }, }), cloudflare({ config: { @@ -240,6 +253,15 @@ export default defineConfig({ copyPublicDir: false, rollupOptions: { plugins: [inject({ Buffer: ['buffer', 'Buffer'] }) as PluginOption], + output: { + manualChunks: (id) => { + if (id.includes('pdfjs-dist')) return 'pdf'; + if (id.includes('@element-hq/element-call-embedded')) return 'element-call'; + if (id.includes('@matrix-org') || id.includes('matrix-js-sdk')) return 'matrix'; + if (id.includes('react-prism') || id.includes('prism')) return 'prism'; + return undefined; + }, + }, }, }, });