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 }, });