Skip to content

Commit 5f19cf1

Browse files
committed
docs: pwa
1 parent 982765b commit 5f19cf1

File tree

1 file changed

+74
-7
lines changed

1 file changed

+74
-7
lines changed

docs/.vitepress/config/index.ts

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,81 @@ export default withPwa(defineConfig({
1212
zh: { label: '简体中文', ...zh }
1313
},
1414
pwa: {
15-
// outDir: resolve(__dirname, '../', 'dist'),
16-
// registerType: 'autoUpdate',
17-
// srcDir: '.vitepress/',
18-
strategies: 'generateSW', // <== if omitted, defaults to `generateSW`
15+
outDir: resolve(__dirname, '../dist'),
16+
registerType: 'prompt',
17+
includeManifestIcons: false,
18+
selfDestroying: true,
19+
manifest: {
20+
id: '/',
21+
name: 'VueHooks plus',
22+
short_name: 'VueHooks plus',
23+
description: 'Highly customizable hooks for Vue',
24+
theme_color: '#ffffff',
25+
icons: [
26+
{
27+
src: 'logo.png',
28+
sizes: '192x192',
29+
type: 'image/png',
30+
},
31+
{
32+
src: 'logo@2.x.png',
33+
sizes: '512x512',
34+
type: 'image/png',
35+
},
36+
{
37+
src: 'logo.svg',
38+
sizes: '155x155',
39+
type: 'image/svg',
40+
purpose: 'any maskable',
41+
},
42+
],
43+
},
1944
workbox: {
45+
globPatterns: ['**/*.{css,js,html,svg,png,ico,txt,woff2}'],
46+
runtimeCaching: [
47+
{
48+
urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i,
49+
handler: 'CacheFirst',
50+
options: {
51+
cacheName: 'google-fonts-cache',
52+
expiration: {
53+
maxEntries: 10,
54+
maxAgeSeconds: 60 * 60 * 24 * 365, // <== 365 days
55+
},
56+
cacheableResponse: {
57+
statuses: [0, 200],
58+
},
59+
},
60+
},
61+
{
62+
urlPattern: /^https:\/\/fonts\.gstatic\.com\/.*/i,
63+
handler: 'CacheFirst',
64+
options: {
65+
cacheName: 'gstatic-fonts-cache',
66+
expiration: {
67+
maxEntries: 10,
68+
maxAgeSeconds: 60 * 60 * 24 * 365, // <== 365 days
69+
},
70+
cacheableResponse: {
71+
statuses: [0, 200],
72+
},
73+
},
74+
},
75+
{
76+
urlPattern: /^https:\/\/cdn\.jsdelivr\.net\/.*/i,
77+
handler: 'NetworkFirst',
78+
options: {
79+
cacheName: 'jsdelivr-images-cache',
80+
expiration: {
81+
maxEntries: 10,
82+
maxAgeSeconds: 60 * 60 * 24 * 7, // <== 7 days
83+
},
84+
cacheableResponse: {
85+
statuses: [0, 200],
86+
},
87+
},
88+
},
89+
],
2090
},
21-
experimental: {
22-
includeAllowlist: true
23-
}
2491
}
2592
}))

0 commit comments

Comments
 (0)