-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
97 lines (94 loc) · 2.72 KB
/
Copy pathvite.config.ts
File metadata and controls
97 lines (94 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { fileURLToPath, URL } from 'node:url';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { compression, defineAlgorithm } from 'vite-plugin-compression2';
import { constants } from 'node:zlib';
import { VitePWA } from 'vite-plugin-pwa';
import { resolve } from 'node:path';
import { statSync } from 'node:fs';
const wasmPath = resolve(__dirname, 'src/assets/core.wasm');
const wasmDecodedSize = statSync(wasmPath).size;
// https://vite.dev/config/
export default defineConfig({
plugins: [
vue(),
// compress wasm files to brotli, zstd and gzip
compression({
include: /\.wasm$/,
algorithms: [
defineAlgorithm('gzip', { level: 9 }),
defineAlgorithm('zstandard', {
params: {
[constants.ZSTD_c_compressionLevel]: 19,
},
}),
defineAlgorithm('brotliCompress', {
params: {
[require('zlib').constants.BROTLI_PARAM_QUALITY]: 11,
},
}),
],
}),
VitePWA({
registerType: 'autoUpdate',
manifest: {
name: 'Git Calendar Web',
short_name: 'Git Cal',
id: '/',
start_url: '/',
scope: '/',
description: 'A web client for a Git-backed calendar.',
display: 'standalone',
background_color: '#ffffff',
theme_color: '#ffffff',
orientation: 'portrait-primary',
icons: [
{
src: '/icon-192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: '/icon-512.png',
sizes: '512x512',
type: 'image/png',
},
],
lang: 'en',
dir: 'ltr',
},
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg,webp,woff2,wasm,zst,br,gz}'],
maximumFileSizeToCacheInBytes: 25 * 1024 * 1024, // 25MiB (core.wasm is a big boy)
cleanupOutdatedCaches: true,
// Let navigation requests reach the network-first route instead of
// resolving `/` directly from the precached `index.html`.
directoryIndex: null,
navigateFallback: null,
runtimeCaching: [
{
urlPattern: ({ request }) => request.mode === 'navigate',
handler: 'NetworkFirst',
options: {
cacheName: 'pages',
fetchOptions: {
cache: 'no-cache',
},
precacheFallback: {
fallbackURL: '/index.html',
},
},
},
],
},
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
define: {
__WASM_DECODED_SIZE__: JSON.stringify(wasmDecodedSize),
},
});