Skip to content

fix: Cloudflare templates break when prerendering is enabled #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cloudflare-d1/react-router.config.ts
Original file line number Diff line number Diff line change
@@ -4,4 +4,5 @@ export default {
// Config options...
// Server-side render by default, to enable SPA mode set this to `false`
ssr: true,
serverBuildFile: "index.js",
} satisfies Config;
19 changes: 18 additions & 1 deletion cloudflare-d1/vite.config.ts
Original file line number Diff line number Diff line change
@@ -9,7 +9,10 @@ export default defineConfig(({ isSsrBuild }) => ({
build: {
rollupOptions: isSsrBuild
? {
input: "./workers/app.ts",
input: {
"index.js": "virtual:react-router/server-build",
"worker.js": "./workers/app.ts",
},
}
: undefined,
},
@@ -48,6 +51,20 @@ export default defineConfig(({ isSsrBuild }) => ({
},
}),
reactRouter(),
{
name: "react-router-cloudflare-workers",
config: () => ({
build: {
rollupOptions: isSsrBuild
? {
output: {
entryFileNames: "[name]",
},
}
: undefined,
},
}),
},
tsconfigPaths(),
],
}));
2 changes: 1 addition & 1 deletion cloudflare-d1/wrangler.toml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ workers_dev = true
name = "my-worker"
compatibility_date = "2024-11-18"
compatibility_flags = ["nodejs_compat"]
main = "./build/server/index.js"
main = "./build/server/worker.js"
assets = { directory = "./build/client/" }

[[d1_databases]]
1 change: 1 addition & 0 deletions cloudflare/react-router.config.ts
Original file line number Diff line number Diff line change
@@ -4,4 +4,5 @@ export default {
// Config options...
// Server-side render by default, to enable SPA mode set this to `false`
ssr: true,
serverBuildFile: "index.js",
} satisfies Config;
19 changes: 18 additions & 1 deletion cloudflare/vite.config.ts
Original file line number Diff line number Diff line change
@@ -9,7 +9,10 @@ export default defineConfig(({ isSsrBuild }) => ({
build: {
rollupOptions: isSsrBuild
? {
input: "./workers/app.ts",
input: {
"index.js": "virtual:react-router/server-build",
"worker.js": "./workers/app.ts",
},
}
: undefined,
},
@@ -44,6 +47,20 @@ export default defineConfig(({ isSsrBuild }) => ({
},
}),
reactRouter(),
{
name: "react-router-cloudflare-workers",
config: () => ({
build: {
rollupOptions: isSsrBuild
? {
output: {
entryFileNames: "[name]",
},
}
: undefined,
},
}),
},
tsconfigPaths(),
],
}));
2 changes: 1 addition & 1 deletion cloudflare/wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
workers_dev = true
name = "my-worker"
compatibility_date = "2024-11-18"
main = "./build/server/index.js"
main = "./build/server/worker.js"
assets = { directory = "./build/client/" }