Skip to content

Commit aaeedd1

Browse files
committed
fix(build): allow PWA build with large wasm assets and split vendor chunks
1 parent 1f74b95 commit aaeedd1

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

vite.config.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,26 @@ export default defineConfig({
185185
VitePWA({
186186
srcDir: 'src',
187187
filename: 'sw.ts',
188-
strategies: 'generateSW',
188+
strategies: 'injectManifest',
189189
injectRegister: false,
190190
manifest: false,
191+
injectManifest: {
192+
injectionPoint: undefined,
193+
},
191194
devOptions: {
192195
enabled: true,
193196
type: 'module',
194197
},
198+
workbox: {
199+
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024, // 10 MB
200+
globIgnores: [
201+
'**/matrix_sdk_crypto_wasm_bg-*.wasm',
202+
'**/vision_wasm_internal-*.wasm',
203+
'**/qcms_bg.wasm',
204+
'**/openjpeg.wasm',
205+
'**/jbig2.wasm',
206+
],
207+
},
195208
}),
196209
cloudflare({
197210
config: {
@@ -247,6 +260,15 @@ export default defineConfig({
247260
copyPublicDir: false,
248261
rollupOptions: {
249262
plugins: [inject({ Buffer: ['buffer', 'Buffer'] })],
263+
output: {
264+
manualChunks: (id) => {
265+
if (id.includes('pdfjs-dist')) return 'pdf';
266+
if (id.includes('@element-hq/element-call-embedded')) return 'element-call';
267+
if (id.includes('@matrix-org') || id.includes('matrix-js-sdk')) return 'matrix';
268+
if (id.includes('react-prism') || id.includes('prism')) return 'prism';
269+
return undefined;
270+
},
271+
},
250272
},
251273
},
252274
});

0 commit comments

Comments
 (0)