Skip to content

Commit 58107b0

Browse files
committed
feat: support local d1
1 parent af8d398 commit 58107b0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

packages/vite-plugin-cloudflare-functions/src/vite/index.ts

+9
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ export function CloudflarePagesFunctions(userConfig: UserConfig = {}): Plugin {
6161
bindings.push(kv);
6262
}
6363
}
64+
if (userConfig.wrangler?.d1) {
65+
const d1s = Array.isArray(userConfig.wrangler.d1)
66+
? userConfig.wrangler.d1
67+
: [userConfig.wrangler.d1];
68+
for (const d1 of d1s) {
69+
bindings.push('--d1');
70+
bindings.push(d1);
71+
}
72+
}
6473
if (userConfig.wrangler?.do) {
6574
for (const [key, value] of Object.entries(userConfig.wrangler.do)) {
6675
bindings.push('--do');

packages/vite-plugin-cloudflare-functions/src/vite/types.ts

+5
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ export interface UserConfig {
5151
*/
5252
kv?: string | string[];
5353

54+
/**
55+
* Bind D1 database
56+
*/
57+
d1?: string | string[];
58+
5459
/**
5560
* Bind Durable Object
5661
*/

0 commit comments

Comments
 (0)