-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
executable file
·54 lines (53 loc) · 1.59 KB
/
Copy pathvite.config.js
File metadata and controls
executable file
·54 lines (53 loc) · 1.59 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
import { defineConfig } from 'vite';
import { VitePWA } from 'vite-plugin-pwa';
export default defineConfig({
plugins: [
VitePWA({
registerType: 'autoUpdate', // 自动更新 Service Worker
includeAssets: [],
manifest: {
name: '作业看板',
short_name: '作业看板',
description: '一个 Material You 风格的作业管理工具',
theme_color: '#6750A4',
background_color: '#F5EFFB',
display: 'standalone',
scope: '/',
start_url: '/',
"icons": [
{
"src": "/assets/favicon_192x.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/assets/favicon_512x.png",
"sizes": "512x512",
"type": "image/png"
}
]
},
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg,txt,woff2}'], // 预缓存文件
globIgnores: ['**/favicon_*.png'], // 排除图标PNG(由manifest icons单独管理)
runtimeCaching: [
{
urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i,
handler: 'CacheFirst',
options: {
cacheName: 'google-fonts-cache',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 365
}
}
}
]
},
devOptions: {
enabled: true, // 开发环境下启用 Service Worker(需要 HTTPS 或 localhost)
type: 'module' // 让 SW 以模块形式运行(便于调试)
}
})
]
});