mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
- Wire up vite-plugin-pwa: generates a web app manifest and a precache-only service worker for the built app shell (JS/CSS/HTML/ icons). WebSocket (/ws) and file-transfer traffic are never intercepted or cached. Disabled in dev so it doesn't interfere with Vite's own HMR websocket. - Add 512px + maskable 512px icons generated from the existing logo. - Add iOS "Add to Home Screen" meta tags (manifest support there is partial). - Gateway: serve .webmanifest with the correct MIME type.
44 lines
1.7 KiB
TypeScript
44 lines
1.7 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import { VitePWA } from 'vite-plugin-pwa'
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
react(),
|
|
VitePWA({
|
|
registerType: 'autoUpdate',
|
|
// Dev-time Workbox would sit in front of Vite's own HMR/WS traffic and
|
|
// stale-cache the app shell while iterating — only ever ship the SW in
|
|
// production builds.
|
|
devOptions: { enabled: false },
|
|
includeAssets: ['favicon.ico', 'apple-touch-icon.png'],
|
|
manifest: {
|
|
name: 'WebSpeak3',
|
|
short_name: 'WebSpeak3',
|
|
description: 'An independent, self-hosted web client for TeamSpeak 3 servers.',
|
|
theme_color: '#03060d',
|
|
background_color: '#03060d',
|
|
display: 'standalone',
|
|
start_url: '.',
|
|
icons: [
|
|
{ src: 'favicon-192.png', sizes: '192x192', type: 'image/png' },
|
|
{ src: 'icon-512.png', sizes: '512x512', type: 'image/png' },
|
|
{ src: 'icon-512-maskable.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' },
|
|
],
|
|
},
|
|
workbox: {
|
|
// Precache the built app shell (JS/CSS/HTML/icons) only. The gateway's
|
|
// /ws endpoint and any file-transfer/API traffic must never be
|
|
// intercepted or cached — Workbox's default fetch handler already
|
|
// ignores non-GET and non-http(s) requests (ws:// isn't touched), so
|
|
// no extra runtimeCaching exclusions are needed here.
|
|
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
|
|
},
|
|
}),
|
|
],
|
|
// Set by the GitHub Pages workflow to the repo subpath (e.g. /webspeak3/);
|
|
// the normal Docker build serves from the domain root and leaves this unset.
|
|
base: process.env.VITE_BASE_PATH || '/',
|
|
})
|