Add an opt-in SSR mode with a Node adapter behind PUBLIC_SSR
This commit is contained in:
parent
9cc82dc1fe
commit
54c0682dce
18 changed files with 4257 additions and 3552 deletions
|
|
@ -1,11 +1,21 @@
|
|||
import adapter from "@sveltejs/adapter-static";
|
||||
import { loadEnv } from "vite";
|
||||
import adapterNode from "@sveltejs/adapter-node";
|
||||
import adapterStatic from "@sveltejs/adapter-static";
|
||||
|
||||
// PUBLIC_SSR picks the deployment target: a Node server that renders pages
|
||||
// (yes) or a static single-page bundle (no, the default). The same flag turns
|
||||
// SSR on in +layout.ts.
|
||||
const env = loadEnv(
|
||||
process.env.NODE_ENV ?? "production",
|
||||
process.cwd(),
|
||||
"PUBLIC_",
|
||||
);
|
||||
const ssr = (process.env.PUBLIC_SSR ?? env.PUBLIC_SSR) === "yes";
|
||||
|
||||
/** @type {import('@sveltejs/kit').Config} */
|
||||
const config = {
|
||||
kit: {
|
||||
adapter: adapter({
|
||||
fallback: "index.html",
|
||||
}),
|
||||
adapter: ssr ? adapterNode() : adapterStatic({ fallback: "index.html" }),
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue