Skip to content

Commit 3c748c8

Browse files
committed
customisable nitro config
1 parent b2be5e9 commit 3c748c8

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

packages/start/src/config/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,22 @@ import path, { isAbsolute, join, normalize } from "node:path";
66
import { fileURLToPath } from "node:url";
77
import { existsSync } from "node:fs";
88
import { StartServerManifest } from "solid-start:server-manifest";
9+
import { type NitroConfig } from "nitropack";
910

1011
import { fsRoutes } from "./fs-routes/index.js";
1112
import { SolidStartClientFileRouter, SolidStartServerFileRouter } from "./fs-router.js";
12-
import { clientDistDir, nitroPlugin, serverDistDir, ssrEntryFile } from "./nitroPlugin.js";
13+
import { clientDistDir, nitroPlugin, serverDistDir, ssrEntryFile, UserNitroConfig } from "./nitroPlugin.js";
1314

1415
const DEFAULT_EXTENSIONS = ["js", "jsx", "ts", "tsx"];
1516

17+
export type { UserNitroConfig } from "./nitroPlugin.js"
18+
1619
export interface SolidStartOptions {
1720
solid?: Partial<SolidOptions>;
1821
ssr?: boolean,
1922
routeDir?: string,
2023
extensions?: string[],
24+
server?: UserNitroConfig
2125
}
2226

2327
const SolidStartServerFnsPlugin = createTanStackServerFnPlugin({
@@ -248,7 +252,7 @@ export default window.manifest;
248252
}
249253
}
250254
},
251-
nitroPlugin({ root: process.cwd() }, () => ssrBundle, handlers),
255+
nitroPlugin({ root: process.cwd() }, () => ssrBundle, start.server),
252256
{
253257
name: "solid-start:capture-client-bundle",
254258
enforce: "post",

packages/start/src/config/nitroPlugin.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ export const clientDistDir = "node_modules/.solid-start/client-dist";
1616
export const serverDistDir = "node_modules/.solid-start/server-dist";
1717
export const ssrEntryFile = "ssr.mjs";
1818

19+
export type UserNitroConfig = Omit<NitroConfig, "dev" | "publicAssets" | "renderer" | "rollupConfig">;
20+
1921
export function nitroPlugin(
2022
options: { root: string },
2123
getSsrBundle: () => Rollup.OutputBundle,
22-
handlers: { client: string; server: string }
24+
nitroConfig?: UserNitroConfig
25+
// handlers: { client: string; server: string }
2326
): Array<PluginOption> {
2427
return [
2528
{
@@ -141,24 +144,23 @@ export function nitroPlugin(
141144
await builder.build(clientEnv);
142145
await builder.build(serverEnv);
143146

144-
const nitroConfig: NitroConfig = {
145-
dev: false,
146-
// TODO do we need this? should this be made configurable?
147+
const resolvedNitroConfig: NitroConfig = {
147148
compatibilityDate: "2024-11-19",
148149
logLevel: 3,
149150
preset: "node-server",
150-
publicAssets: [{ dir: path.resolve(options.root, clientDistDir) }],
151151
typescript: {
152152
generateTsConfig: false
153153
},
154-
prerender: undefined,
154+
...nitroConfig,
155+
dev: false,
156+
publicAssets: [{ dir: path.resolve(options.root, clientDistDir) }],
155157
renderer: ssrEntryFile,
156158
rollupConfig: {
157159
plugins: [virtualBundlePlugin(getSsrBundle()) as any]
158-
}
160+
},
159161
};
160162

161-
const nitro = await createNitro(nitroConfig);
163+
const nitro = await createNitro(resolvedNitroConfig);
162164

163165
await buildNitroEnvironment(nitro, () => build(nitro));
164166
}

0 commit comments

Comments
 (0)