update
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
"scripts": {
|
||||
"dev": "vite dev --host --strictPort",
|
||||
"build": "vite build",
|
||||
"build:lowmem": "node ../../scripts/build.mjs --web",
|
||||
"start": "node build",
|
||||
"preview": "vite preview",
|
||||
"prepare": "svelte-kit sync || echo '' && node scripts/copy-rapidoc-ui.mjs",
|
||||
|
||||
@@ -4,13 +4,35 @@ 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.
|
||||
|
||||
Reference in New Issue
Block a user