LazyBoy2/web/vite.config.ts

39 lines
1.2 KiB
TypeScript
Raw Normal View History

2026-09-16 07:06:53 +00:00
import { dirname, resolve } from "node:path";
2026-09-15 09:07:16 +00:00
import { fileURLToPath } from "node:url";
import { defineConfig, loadEnv, type ServerOptions } from "vite";
2026-09-14 09:08:20 +00:00
import react from "@vitejs/plugin-react";
2026-09-15 09:07:16 +00:00
const rootDir = resolve(dirname(fileURLToPath(import.meta.url)), "..");
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, rootDir, "");
const version = (process.env.LAZYBOY_VERSION || env.LAZYBOY_VERSION || "0.1.0").trim() || "0.1.0";
2026-09-16 07:06:53 +00:00
// The API accepts HTTP even when its optional TLS listener is enabled.
const backendPort = process.env.LAZYBOY_WEB_PORT || env.LAZYBOY_WEB_PORT || "8787";
const backend = `http://127.0.0.1:${backendPort}`;
2026-09-15 09:07:16 +00:00
const server: ServerOptions = {
2026-09-14 09:08:20 +00:00
port: 5173,
2026-09-16 07:06:53 +00:00
host: "0.0.0.0",
strictPort: true,
2026-09-14 09:08:20 +00:00
proxy: {
2026-09-15 09:07:16 +00:00
"/api": { target: backend, secure: false },
"/novnc": { target: backend, ws: true, secure: false },
"/lazyboy-ca.crt": { target: backend, secure: false },
},
};
return {
plugins: [react()],
2026-09-16 08:17:38 +00:00
resolve: { dedupe: ["react", "react-dom"] },
2026-09-15 09:07:16 +00:00
define: {
"import.meta.env.LAZYBOY_VERSION": JSON.stringify(version),
2026-09-14 09:08:20 +00:00
},
2026-09-15 09:07:16 +00:00
server,
preview: {
port: 4173,
2026-09-16 07:06:53 +00:00
host: "0.0.0.0",
strictPort: true,
2026-09-15 09:07:16 +00:00
},
};
2026-09-14 09:08:20 +00:00
});
2026-09-15 09:07:16 +00:00