-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
42 lines (40 loc) · 895 Bytes
/
vite.config.ts
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
import { VitePWA } from 'vite-plugin-pwa';
import { defineConfig } from 'vite';
const DEBUG_SW = false;
// https://vitejs.dev/config/
export default defineConfig({
build: {
target: 'esnext',
lib: {
entry: 'index.html',
formats: ['es'],
},
},
plugins: [
VitePWA({
registerType: 'autoUpdate',
...(DEBUG_SW
? {
devOptions: {
enabled: true,
},
}
: {}),
workbox: {
runtimeCaching: [
{
urlPattern: ({ url }) => url.pathname.includes('/api/search'),
handler: 'CacheFirst',
options: {
cacheName: 'api-search-cache',
expiration: {
maxEntries: 15,
maxAgeSeconds: 60 * 60 * 24 * 7, // 1 week
},
},
},
],
},
}),
],
});