From 63daa6483a089c0d54813c9f7e942d411204f606 Mon Sep 17 00:00:00 2001 From: James Date: Sun, 13 Oct 2024 17:46:09 +0100 Subject: [PATCH] fix: copying excess files to output directory --- .changeset/sixty-years-cheat.md | 7 +++++++ packages/cloudflare/src/cli/build/index.ts | 8 ++++++-- packages/cloudflare/src/cli/config.ts | 3 --- 3 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 .changeset/sixty-years-cheat.md diff --git a/.changeset/sixty-years-cheat.md b/.changeset/sixty-years-cheat.md new file mode 100644 index 00000000..2fc21e05 --- /dev/null +++ b/.changeset/sixty-years-cheat.md @@ -0,0 +1,7 @@ +--- +"@opennextjs/cloudflare": patch +--- + +fix: copying excess files to output directory + +In previous versions, we copied the entire `.next` directory to the `.worker-next` output directory. Going forward, it will only copy the `.next/standalone` directory to this location. diff --git a/packages/cloudflare/src/cli/build/index.ts b/packages/cloudflare/src/cli/build/index.ts index 87b84cda..5ced343c 100644 --- a/packages/cloudflare/src/cli/build/index.ts +++ b/packages/cloudflare/src/cli/build/index.ts @@ -27,8 +27,12 @@ export async function build(projectOpts: ProjectOptions): Promise { // Clean the output directory await cleanDirectory(projectOpts.outputDir); - // Copy the .next directory to the output directory so it can be mutated. - cpSync(join(projectOpts.sourceDir, ".next"), join(projectOpts.outputDir, ".next"), { recursive: true }); + // Copy the .next/standalone directory to the output directory so it can be mutated. + cpSync( + join(projectOpts.sourceDir, ".next", "standalone"), + join(projectOpts.outputDir, ".next", "standalone"), + { recursive: true } + ); const config = getConfig(projectOpts); diff --git a/packages/cloudflare/src/cli/config.ts b/packages/cloudflare/src/cli/config.ts index eb101e0c..62fa95e4 100644 --- a/packages/cloudflare/src/cli/config.ts +++ b/packages/cloudflare/src/cli/config.ts @@ -27,8 +27,6 @@ export type Config = { root: string; // Path to the OpenNext static assets directory assets: string; - // Path to the app's `.next` directory in the OpenNext output directory - dotNext: string; // Path to the application standalone root directory standaloneRoot: string; // Path to the application standalone directory (where `next build` saves the standalone app) @@ -92,7 +90,6 @@ export function getConfig(projectOpts: ProjectOptions): Config { output: { root: projectOpts.outputDir, assets: join(projectOpts.outputDir, "assets"), - dotNext, standaloneRoot, standaloneApp, standaloneAppDotNext,