Skip to content

Commit

Permalink
feat: support more clear do config
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Oct 26, 2023
1 parent 0cf1124 commit dba836d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/vite-plugin-cloudflare-functions/src/vite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ export function CloudflarePagesFunctions(userConfig: UserConfig = {}): Plugin {
}
if (userConfig.wrangler?.do) {
for (const [key, value] of Object.entries(userConfig.wrangler.do)) {
const config = typeof value === 'string' ? value : `${value.class}@${value.script}`;
bindings.push('--do');
bindings.push(`"${key}=${value}"`);
bindings.push(`"${key}=${config}"`);
}
}
if (userConfig.wrangler?.r2) {
Expand Down
4 changes: 2 additions & 2 deletions packages/vite-plugin-cloudflare-functions/src/vite/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ export interface UserConfig {
/**
* Bind Durable Object
*/
do?: Record<string, string>;
do?: Record<string, string | { class: string; script: string }>;

/**
* Bind R2 bucket
*/
r2?: string | string[];

/**
* Determines which version of the Workers runtime is used.
* Determines which version of the Workers runtime is used.
*/
compatibilityDate?: string;
};
Expand Down

0 comments on commit dba836d

Please sign in to comment.