Add PWA installability (manifest + service worker)

- 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.
This commit is contained in:
Moepchi committed 2026-09-07 16:16:44 +02:00
1 parent 20d1944dc9
commit 48f5e35a38
7 files changed
+5360 -3

No files matched your search

+1
View File
@@ -41,6 +41,7 @@ const MIME_TYPES: Record<string, string> = {
".ico": "image/x-icon",
".json": "application/json",
".woff2": "font/woff2",
".webmanifest": "application/manifest+json",
};
const DEV_HINT = `<!doctype html><html><body style="font:14px system-ui;padding:2rem;max-width:40rem">
+7
View File
@@ -7,6 +7,13 @@
<link rel="icon" type="image/png" sizes="192x192" href="/favicon-192.png" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#03060d" />
<!-- iOS ignores most of the Web App Manifest — these are the fields it
actually reads for "Add to Home Screen" (standalone display, status
bar style, home-screen title). -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="WebSpeak3" />
<title>WebSpeak3</title>
<meta name="description" content="WebSpeak3 — an independent, self-hosted web client for TeamSpeak 3 servers." />
+5316 -1
View File
File diff suppressed because it is too large. Load diff
+2 -1
View File
@@ -21,6 +21,7 @@
"@vitejs/plugin-react": "^6.0.3",
"oxlint": "^1.71.0",
"typescript": "~6.0.2",
"vite": "^8.1.1"
"vite": "^8.1.1",
"vite-plugin-pwa": "^1.3.0"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 KiB

+34 -1
View File
@@ -1,9 +1,42 @@
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()],
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 || '/',