Skip to content
Closed
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/whole-coats-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/cloudflare": minor
---

Add ability to pass multiple configuration files to the dev server
9 changes: 6 additions & 3 deletions packages/cloudflare/src/cli/commands/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export function withWranglerOptions<T extends yargs.Argv>(args: T) {

type WranglerInputArgs = {
configPath: string | undefined;
config: string | undefined;
config: string | string[] | undefined;
env: string | undefined;
remote?: boolean | undefined;
};
Expand All @@ -151,9 +151,11 @@ function getWranglerArgs(args: WranglerInputArgs & { _: (string | number)[] }):
}
}

const configValues = [args.config].flat().filter((v): v is string => Boolean(v));

return [
...(args.configPath ? ["--config", args.configPath] : []),
...(args.config ? ["--config", args.config] : []),
...(configValues.length > 0 ? configValues.flatMap((config) => ["--config", config]) : []),
...(args.env ? ["--env", args.env] : []),
...(args.remote ? ["--remote"] : []),
// Note: the first args in `_` will be the commands.
Expand All @@ -169,9 +171,10 @@ function getWranglerArgs(args: WranglerInputArgs & { _: (string | number)[] }):
export function withWranglerPassthroughArgs<T extends yargs.ArgumentsCamelCase<WranglerInputArgs>>(
args: T
): WithWranglerArgs<T> {
const [config] = [args.config].flat().filter(Boolean);
return {
...args,
wranglerConfigPath: args.config ?? args.configPath,
wranglerConfigPath: config ?? args.configPath,
wranglerArgs: getWranglerArgs(args),
};
}