Files
hapi/web/vite.config.ts
T
weishu be00343289 feat: add iOS Safari install guide and improve PWA UX with neutral theme
- Add iOS Safari install prompt with step-by-step modal guide
- Fix Telegram environment detection (check initData, not just SDK presence)
- Fix install prompt re-entrancy issue (clear deferredPrompt immediately)
- Extract icon components to separate file (web/src/components/icons.tsx)
- Rename "Happy App" to "Hapi" throughout the UI and manifests
- Change button/icon colors from blue (--app-button) to neutral theme (--app-fg/--app-bg)
- Add install dismiss state to prevent repeated prompts
- Improve iOS Safari detection with robust user agent parsing
2025-12-18 14:05:50 +08:00

126 lines
4.3 KiB
TypeScript

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { VitePWA } from 'vite-plugin-pwa'
import { resolve } from 'node:path'
export default defineConfig({
plugins: [
react(),
VitePWA({
registerType: 'autoUpdate',
includeAssets: ['favicon.ico', 'apple-touch-icon-180x180.png', 'mask-icon.svg'],
manifest: {
name: 'Hapi',
short_name: 'Hapi',
description: 'AI-powered development assistant',
theme_color: '#ffffff',
background_color: '#ffffff',
display: 'standalone',
orientation: 'portrait',
scope: '/',
start_url: '/',
icons: [
{
src: 'pwa-64x64.png',
sizes: '64x64',
type: 'image/png'
},
{
src: 'pwa-192x192.png',
sizes: '192x192',
type: 'image/png'
},
{
src: 'pwa-512x512.png',
sizes: '512x512',
type: 'image/png'
},
{
src: 'maskable-icon-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'maskable'
}
]
},
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff,woff2}'],
runtimeCaching: [
{
urlPattern: /^\/api\/sessions$/,
handler: 'NetworkFirst',
options: {
cacheName: 'api-sessions',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 5
},
networkTimeoutSeconds: 10
}
},
{
urlPattern: /^\/api\/sessions\/[^/]+$/,
handler: 'NetworkFirst',
options: {
cacheName: 'api-session-detail',
expiration: {
maxEntries: 20,
maxAgeSeconds: 60 * 5
},
networkTimeoutSeconds: 10
}
},
{
urlPattern: /^\/api\/machines$/,
handler: 'NetworkFirst',
options: {
cacheName: 'api-machines',
expiration: {
maxEntries: 5,
maxAgeSeconds: 60 * 10
},
networkTimeoutSeconds: 10
}
},
{
urlPattern: /^https:\/\/cdn\.socket\.io\/.*/,
handler: 'CacheFirst',
options: {
cacheName: 'cdn-socketio',
expiration: {
maxEntries: 5,
maxAgeSeconds: 60 * 60 * 24 * 30
}
}
},
{
urlPattern: /^https:\/\/telegram\.org\/.*/,
handler: 'CacheFirst',
options: {
cacheName: 'cdn-telegram',
expiration: {
maxEntries: 5,
maxAgeSeconds: 60 * 60 * 24 * 7
}
}
}
]
},
devOptions: {
enabled: true,
type: 'module'
}
})
],
base: '/',
resolve: {
alias: {
'@': resolve(__dirname, 'src')
}
},
build: {
outDir: 'dist',
emptyOutDir: true
}
})