49 lines
1.8 KiB
TypeScript
49 lines
1.8 KiB
TypeScript
import tailwindcss from "@tailwindcss/vite";
|
|
import { sveltekit } from "@sveltejs/kit/vite";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { defineConfig } from "vite";
|
|
import { DEV_API_PROXY_TARGET, DEV_WEB_PORT } from "../../scripts/dev-ports.mjs";
|
|
import { detectHostProfile } from "../../scripts/lowmem-env.mjs";
|
|
|
|
const monorepoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
|
|
|
const profile = detectHostProfile();
|
|
/** Env wins; otherwise follow auto RAM/CPU tier. */
|
|
const lowMem =
|
|
process.env.BUILD_LOW_MEM != null && process.env.BUILD_LOW_MEM !== ""
|
|
? process.env.BUILD_LOW_MEM !== "0"
|
|
: profile.lowMem;
|
|
|
|
export default defineConfig({
|
|
// Load PUBLIC_* from monorepo-root .env (same file as the Go API).
|
|
envDir: monorepoRoot,
|
|
plugins: [tailwindcss(), sveltekit()],
|
|
build: {
|
|
// Gzip size reporting double-reads output and spikes peak RSS on tiny hosts.
|
|
reportCompressedSize: !lowMem,
|
|
// Production maps are opt-in; maps roughly double transform memory.
|
|
sourcemap: process.env.BUILD_SOURCEMAP === "1",
|
|
// Smaller inlined assets → less heap during transform on 4GB boxes.
|
|
assetsInlineLimit: lowMem ? 1024 : 4096,
|
|
rolldownOptions: {
|
|
checks: {
|
|
// Informative only; sveltekit-guard resolveId dominates wall time (see Rolldown docs).
|
|
pluginTimings: process.env.BUILD_PLUGIN_TIMINGS === "1"
|
|
}
|
|
}
|
|
},
|
|
server: {
|
|
// true → all interfaces (IPv4 + IPv6). Default localhost is ::1-only on Windows,
|
|
// which breaks 127.0.0.1 probes and some browser Happy Eyeballs paths.
|
|
host: true,
|
|
port: DEV_WEB_PORT,
|
|
strictPort: true,
|
|
proxy: {
|
|
"/api": { target: DEV_API_PROXY_TARGET, changeOrigin: true },
|
|
"/healthz": { target: DEV_API_PROXY_TARGET, changeOrigin: true },
|
|
"/readyz": { target: DEV_API_PROXY_TARGET, changeOrigin: true }
|
|
}
|
|
}
|
|
});
|