monal-rebuild/vite.config.ts
pijukka e009e615f4 PWA: manifest, icons, service worker
- Installable app: manifest, SVG icon plus PNGs (192, 512, maskable 512,
  apple-touch 180), theme color and iOS meta tags.
- Service worker (production builds only): precaches the page and the
  bundles it references on install (Chromium's memory cache bypasses the
  worker on repeat loads), cache-first for hashed assets, network-first
  for the page and config.js so deploys land at once; ignores Vary
  (module scripts carry an Origin header). Uploads, the websocket and
  anything cross-origin are never touched. Checked in a production
  preview: worker controls the page, and the app opens offline.
- Notifications fall back to the service worker where browsers require
  it (Android), which also handles the click.
- `npm run preview` gets the dev proxy, so the installed app can log in
  locally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 18:31:29 +02:00

29 lines
882 B
TypeScript

import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
// Dev only: the XMPP websocket is proxied to the real server so the app runs
// same-origin, as it does in production. Prosody checks the Origin header
// against cross_domain_websocket, so the proxy presents the production one.
const upstream = process.env.XMPP_UPSTREAM ?? "https://chat.0ff.space";
const proxy = {
"/xmpp-websocket": {
target: upstream,
ws: true,
changeOrigin: true,
headers: { Origin: upstream },
},
};
export default defineConfig({
plugins: [svelte()],
base: "./",
build: {
// Chrome/WebView 80+, Safari 14+, Firefox 78+ (PLAN.md, Decisions).
target: "es2020",
},
server: { proxy },
// `npm run preview` serves the production build (with the service worker)
// and needs the same proxy to log in.
preview: { proxy },
});