Skip to content

Commit

Permalink
Update Migration Instructions for Cloudflare Pages (#9118)
Browse files Browse the repository at this point in the history
  • Loading branch information
xdivby0 committed Mar 25, 2024
1 parent b85643d commit 635802a
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions docs/future/vite.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,27 +453,20 @@ The Remix Vite plugin only officially supports [Cloudflare Pages][cloudflare-pag

</docs-warning>

👉 **Setup the Cloudflare Remix preset, then add `"workerd"` and `"worker"` conditions**
👉 add `cloudflareDevProxyVitePlugin` **before** `remix` plugin to correctly override vite dev server's middleware!

```ts filename=vite.config.ts lines=[3,6,11,14-18]
```ts filename=vite.config.ts lines=[3,9]
import {
vitePlugin as remix,
cloudflarePreset as cloudflare,
cloudflareDevProxyVitePlugin,
} from "@remix-run/dev";
import { defineConfig } from "vite";
import { getBindingsProxy } from "wrangler";

export default defineConfig({
plugins: [
remix({
presets: [cloudflare(getBindingsProxy)],
}),
],
ssr: {
resolve: {
externalConditions: ["workerd", "worker"],
},
},
cloudflareDevProxyVitePlugin(),
remix(),
]
});
```

Expand All @@ -487,13 +480,15 @@ Instead, you can author a catch-all route directly for Cloudflare, just like how
import { createPagesFunctionHandler } from "@remix-run/cloudflare-pages";

// @ts-ignore - the server build file is generated by `remix vite:build`
import * as build from "../build/server";
import * as build from "../build/server";

export const onRequest = createPagesFunctionHandler({
build,
});
```

👉 **Access Bindings and Environment Variables through `context.cloudflare.env` instead of `context.env`**

While you'll mostly use Vite during development, you can also use Wrangler to preview and deploy your app.
To learn more, see [_Cloudflare > Vite & Wrangler_][cloudflare-vite-and-wrangler].

Expand Down

0 comments on commit 635802a

Please sign in to comment.