diff --git a/examples/create-next-app/public/next.svg b/examples/create-next-app/public/next.svg new file mode 100644 index 00000000..5174b28c --- /dev/null +++ b/examples/create-next-app/public/next.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/examples/create-next-app/public/vercel.svg b/examples/create-next-app/public/vercel.svg new file mode 100644 index 00000000..d2f84222 --- /dev/null +++ b/examples/create-next-app/public/vercel.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/examples/create-next-app/src/app/page.tsx b/examples/create-next-app/src/app/page.tsx index 1179ed2a..25977bc4 100644 --- a/examples/create-next-app/src/app/page.tsx +++ b/examples/create-next-app/src/app/page.tsx @@ -2,94 +2,110 @@ import Image from "next/image"; export default function Home() { return ( -
-
- Next.js logo -
    -
  1. - Get started by editing{" "} - - src/app/page.tsx - - . -
  2. -
  3. Save and see your changes instantly.
  4. -
- -
+
+
+

+ Get started by editing  + src/app/page.tsx +

+ -
-
+
+ +
+ Next.js Logo +
+ +
+ +

+ Docs{" "} + + -> + +

+

+ Find in-depth information about Next.js features and API. +

+
+ - File icon - Learn +

+ Learn{" "} + + -> + +

+

+ Learn about Next.js in an interactive course with quizzes! +

+ - Window icon - Examples +

+ Templates{" "} + + -> + +

+

Explore starter templates for Next.js.

+ - Globe icon - Go to nextjs.org → +

+ Deploy{" "} + + -> + +

+

+ Instantly deploy your Next.js site to a shareable URL with Vercel. +

- -
+
+ ); } diff --git a/packages/cloudflare/src/build/build-worker.ts b/packages/cloudflare/src/build/build-worker.ts index 94165d41..349482a2 100644 --- a/packages/cloudflare/src/build/build-worker.ts +++ b/packages/cloudflare/src/build/build-worker.ts @@ -1,6 +1,6 @@ import { NextjsAppPaths } from "../nextjs-paths"; import { build, Plugin } from "esbuild"; -import { readFileSync } from "node:fs"; +import { existsSync, readFileSync } from "node:fs"; import { cp, readFile, writeFile } from "node:fs/promises"; import { patchRequire } from "./patches/investigated/patch-require"; @@ -20,6 +20,7 @@ import { updateWebpackChunksFile } from "./patches/investigated/update-webpack-c * @param nextjsAppPaths */ export async function buildWorker( + inputNextAppDir: string, outputDir: string, nextjsAppPaths: NextjsAppPaths, templateSrcDir: string @@ -124,10 +125,19 @@ Request = globalThis.Request; await updateWorkerBundledCode(workerOutputFile, nextjsAppPaths); console.log(`\x1b[35m⚙️ Copying asset files...\n\x1b[0m`); + + // Copy over client-side generated files await cp(`${nextjsAppPaths.dotNextDir}/static`, `${outputDir}/assets/_next/static`, { recursive: true, }); + // Copy over any static files (e.g. images) from the source project + if (existsSync(`${inputNextAppDir}/public`)) { + await cp(`${inputNextAppDir}/public`, `${outputDir}/assets`, { + recursive: true, + }); + } + console.log(`\x1b[35mWorker saved in \`${workerOutputFile}\` 🚀\n\x1b[0m`); } diff --git a/packages/cloudflare/src/build/build.ts b/packages/cloudflare/src/build/build.ts index e4bbec39..add90c5d 100644 --- a/packages/cloudflare/src/build/build.ts +++ b/packages/cloudflare/src/build/build.ts @@ -43,7 +43,7 @@ export async function build(inputNextAppDir: string, opts: BuildOptions): Promis const templateDir = path.join(path.dirname(fileURLToPath(import.meta.url)), "templates"); - await buildWorker(outputDir, nextjsAppPaths, templateDir); + await buildWorker(inputNextAppDir, outputDir, nextjsAppPaths, templateDir); } type BuildOptions = {