-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
81 lines (79 loc) · 2.43 KB
/
Copy pathvite.config.ts
File metadata and controls
81 lines (79 loc) · 2.43 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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { VitePWA } from 'vite-plugin-pwa'
import path from 'path'
import { writeFileSync } from 'fs'
// Generate build version (timestamp + random suffix)
const buildVersion = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`
export default defineConfig({
plugins: [
react(),
VitePWA({
registerType: 'autoUpdate',
includeAssets: ['favicon.svg', 'robots.txt', 'apple-touch-icon.png'],
manifest: {
name: 'FunkPilot - Amateurfunk Assistent',
short_name: 'FunkPilot',
description: 'KI-gestützter Amateurfunk-Assistent',
theme_color: '#1e3a5f',
background_color: '#0f172a',
display: 'standalone',
orientation: 'portrait-primary',
start_url: '/',
scope: '/',
icons: [
{ src: 'pwa-192x192.png', sizes: '192x192', type: 'image/png' },
{ src: 'pwa-512x512.png', sizes: '512x512', type: 'image/png' },
{ src: 'pwa-512x512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' }
]
},
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
// Skip waiting ensures new service worker activates immediately
skipWaiting: true,
clientsClaim: true,
runtimeCaching: [
{
urlPattern: /^https:\/\/api\.hamqth\.com/,
handler: 'NetworkFirst',
options: {
cacheName: 'hamqth-cache',
expiration: { maxEntries: 50, maxAgeSeconds: 3600 }
}
},
{
urlPattern: /^https:\/\/funkpilot\.oeradio\.at\/api/,
handler: 'NetworkFirst',
options: {
cacheName: 'api-cache',
expiration: { maxEntries: 100, maxAgeSeconds: 300 }
}
}
]
}
}),
{
name: 'generate-version',
closeBundle() {
// Write version to dist folder after build
writeFileSync(
path.resolve(__dirname, 'dist', 'version.json'),
JSON.stringify({ version: buildVersion, buildTime: new Date().toISOString() })
)
console.log(`Build version: ${buildVersion}`)
},
},
],
define: {
__BUILD_VERSION__: JSON.stringify(buildVersion),
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
server: {
port: 5173,
host: true,
},
})