Files
stpweb/vue/vite.config.js
adamfandClaude Opus 5.5 4530cb8dc4
Test and deploy / test (push) Successful in 28s
Test and deploy / deploy (push) Successful in 31s
Trim comments to the non-obvious why
Drop narration, history and restated-code comments across the repo,
keep short ones for security boundaries, upstream quirks and ordering
constraints, and record the convention in CLAUDE.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 20:49:03 +00:00

56 lines
1.7 KiB
JavaScript

import { fileURLToPath, URL } from "node:url";
import { defineConfig, loadEnv } from "vite";
import tailwindcss from "@tailwindcss/vite";
import vue from "@vitejs/plugin-vue";
import vueDevTools from "vite-plugin-vue-devtools";
// Dev-server proxy targets. Compose publishes none of these services, so the
// defaults are each service's own port on the host; /py and /radio share
// :8000, so at most one is right. Override with VITE_PROXY_API, _GITEA, _PY
// and _RADIO (shell or vue/.env.local). API, GITEA and RADIO may point at a
// running Caddy; PY may not (see the rewrite below).
const DEFAULT_PROXY = {
VITE_PROXY_API: "http://localhost:8080",
VITE_PROXY_GITEA: "http://localhost:3000",
VITE_PROXY_PY: "http://localhost:8000",
VITE_PROXY_RADIO: "http://localhost:8000",
};
// https://vite.dev/config/
export default defineConfig(({ mode }) => {
// process.env wins over the .env files.
const env = {
...DEFAULT_PROXY,
...loadEnv(mode, process.cwd(), "VITE_PROXY_"),
};
for (const key of Object.keys(DEFAULT_PROXY))
if (process.env[key]) env[key] = process.env[key];
return {
plugins: [
vue(),
...(process.env.NODE_ENV !== "production" ? [vueDevTools()] : []),
tailwindcss(),
],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
server: {
host: "0.0.0.0",
proxy: {
"/api": env.VITE_PROXY_API,
"/gitea": env.VITE_PROXY_GITEA,
"/radio": env.VITE_PROXY_RADIO,
// Caddy strips /py, so this must target uvicorn directly.
"/py": {
target: env.VITE_PROXY_PY,
rewrite: (path) => path.replace(/^\/py/, ""),
},
},
},
};
});