-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
68 lines (67 loc) · 1.76 KB
/
Copy pathvite.config.ts
File metadata and controls
68 lines (67 loc) · 1.76 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
import react from '@vitejs/plugin-react'
import path from 'path'
import { defineConfig } from 'vitest/config'
import { VitePWA } from 'vite-plugin-pwa'
export default defineConfig({
plugins: [
react(),
// v0.11.0:PWA — 离线壳 + 安装到桌面/主屏。完全不动 UI。
VitePWA({
registerType: 'autoUpdate',
workbox: {
globPatterns: ['**/*.{js,css,ico,png,svg,woff2}'],
navigateFallbackDenylist: [/^\/api\//],
runtimeCaching: [
{
urlPattern: ({ url }) => url.pathname.startsWith('/api/'),
handler: 'NetworkOnly',
},
],
},
manifest: {
name: 'SnapImg',
short_name: 'SnapImg',
description: '保色无损图片压缩 — 浏览器本地化、隐私优先',
theme_color: '#0f172a',
background_color: '#ffffff',
display: 'standalone',
start_url: '/',
icons: [
// 用现有 vite.svg 作 fallback;实际部署可替换为 PNG 192/512
{ src: '/vite.svg', sizes: 'any', type: 'image/svg+xml', purpose: 'any maskable' },
],
},
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
server: {
host: '0.0.0.0',
proxy: {
'/api': {
target: 'http://127.0.0.1:8001',
changeOrigin: true,
},
},
},
test: {
environment: 'jsdom',
globals: true,
setupFiles: ['./vitest.setup.ts'],
include: ['src/**/*.{test,spec}.{ts,tsx}'],
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
include: ['src/**/*.{ts,tsx}'],
exclude: [
'src/main.tsx',
'src/**/*.d.ts',
'src/**/*.test.{ts,tsx}',
'src/**/*.spec.{ts,tsx}',
],
},
},
})