Skip to content

Commit 9c1c936

Browse files
huseeiinbrenelz
andauthored
fix netlify-static & netlify-edge presets (#2050)
Co-authored-by: Brenley Dueck <brenleydueck@gmail.com>
1 parent a9cd2cc commit 9c1c936

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

.changeset/fresh-eyes-bet.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/vite-plugin-nitro-2": minor
3+
---
4+
5+
fix edge presets like netlify and cloudflare

packages/start-nitro-v2-vite-plugin/src/index.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ export function nitroV2Plugin(nitroConfig?: UserNitroConfig): PluginOption {
8484
},
8585
...nitroConfig,
8686
dev: false,
87+
routeRules: {
88+
"/_build/assets/**": {
89+
headers: {
90+
"cache-control": "public, immutable, max-age=31536000",
91+
},
92+
},
93+
},
8794
publicAssets: [
8895
{
8996
dir: client.config.build.outDir,
@@ -117,14 +124,19 @@ export function nitroV2Plugin(nitroConfig?: UserNitroConfig): PluginOption {
117124
};
118125
},
119126
},
120-
nitroConfig?.preset === "netlify" && {
121-
name: "solid-start-nitro-netlify-fix",
127+
{
128+
name: "solid-start-nitro-edge-fix",
122129
enforce: "post",
123-
config() {
130+
async config() {
131+
await fsp.rm(".solid-start", { recursive: true, force: true });
124132
return {
125133
environments: {
126134
client: { build: { outDir: ".solid-start/client" } },
127-
ssr: { build: { outDir: ".solid-start/server" } },
135+
ssr: {
136+
build: nitroConfig?.preset?.toLowerCase().includes("static")
137+
? undefined
138+
: { outDir: ".solid-start/server" },
139+
},
128140
},
129141
};
130142
},

0 commit comments

Comments
 (0)