diff --git a/.changeset/whole-coats-poke.md b/.changeset/whole-coats-poke.md new file mode 100644 index 000000000..61f6a9a4c --- /dev/null +++ b/.changeset/whole-coats-poke.md @@ -0,0 +1,5 @@ +--- +"@opennextjs/cloudflare": minor +--- + +Add ability to pass multiple configuration files to the dev server diff --git a/packages/cloudflare/src/cli/commands/utils.ts b/packages/cloudflare/src/cli/commands/utils.ts index 4bed37d4b..6b71e4dbd 100644 --- a/packages/cloudflare/src/cli/commands/utils.ts +++ b/packages/cloudflare/src/cli/commands/utils.ts @@ -129,7 +129,7 @@ export function withWranglerOptions(args: T) { type WranglerInputArgs = { configPath: string | undefined; - config: string | undefined; + config: string | string[] | undefined; env: string | undefined; remote?: boolean | undefined; }; @@ -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. @@ -169,9 +171,10 @@ function getWranglerArgs(args: WranglerInputArgs & { _: (string | number)[] }): export function withWranglerPassthroughArgs>( args: T ): WithWranglerArgs { + const [config] = [args.config].flat().filter(Boolean); return { ...args, - wranglerConfigPath: args.config ?? args.configPath, + wranglerConfigPath: config ?? args.configPath, wranglerArgs: getWranglerArgs(args), }; }