Skip to content

Commit

Permalink
template
Browse files Browse the repository at this point in the history
  • Loading branch information
pcattori committed Feb 14, 2024
1 parent d16d9a8 commit 57ba779
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
12 changes: 5 additions & 7 deletions templates/vite-cloudflare/load-context.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { type KVNamespace } from "@cloudflare/workers-types";
import { type PlatformProxy } from "wrangler";

// In the future, types for bindings will be generated by `wrangler types`
// See https://github.com/cloudflare/workers-sdk/pull/4931
type Bindings = {
// Add types for bindings configured in `wrangler.toml`
MY_KV: KVNamespace;
};
// TODO: generate Env via `wrangler types`
type Env = { MY_KV: KVNamespace };
type Cloudflare = Omit<PlatformProxy<Env>, "dispose">;

declare module "@remix-run/cloudflare" {
interface AppLoadContext {
env: Bindings;
cloudflare: Cloudflare;
}
}
15 changes: 2 additions & 13 deletions templates/vite-cloudflare/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
import {
vitePlugin as remix,
cloudflarePreset as cloudflare,
cloudflareProxyVitePlugin as remixCloudflareProxy,
} from "@remix-run/dev";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import { getBindingsProxy } from "wrangler";

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

0 comments on commit 57ba779

Please sign in to comment.