1
1
import { NextjsAppPaths } from "../nextjs-paths" ;
2
2
import { build , Plugin } from "esbuild" ;
3
- import { readFileSync } from "node:fs" ;
3
+ import { existsSync , readFileSync } from "node:fs" ;
4
4
import { cp , readFile , writeFile } from "node:fs/promises" ;
5
5
6
6
import { patchRequire } from "./patches/investigated/patch-require" ;
@@ -20,6 +20,7 @@ import { updateWebpackChunksFile } from "./patches/investigated/update-webpack-c
20
20
* @param nextjsAppPaths
21
21
*/
22
22
export async function buildWorker (
23
+ inputNextAppDir : string ,
23
24
outputDir : string ,
24
25
nextjsAppPaths : NextjsAppPaths ,
25
26
templateSrcDir : string
@@ -124,10 +125,19 @@ Request = globalThis.Request;
124
125
await updateWorkerBundledCode ( workerOutputFile , nextjsAppPaths ) ;
125
126
126
127
console . log ( `\x1b[35m⚙️ Copying asset files...\n\x1b[0m` ) ;
128
+
129
+ // Copy over client-side generated files
127
130
await cp ( `${ nextjsAppPaths . dotNextDir } /static` , `${ outputDir } /assets/_next/static` , {
128
131
recursive : true ,
129
132
} ) ;
130
133
134
+ // Copy over any static files (e.g. images) from the source project
135
+ if ( existsSync ( `${ inputNextAppDir } /public` ) ) {
136
+ await cp ( `${ inputNextAppDir } /public` , `${ outputDir } /assets` , {
137
+ recursive : true ,
138
+ } ) ;
139
+ }
140
+
131
141
console . log ( `\x1b[35mWorker saved in \`${ workerOutputFile } \` 🚀\n\x1b[0m` ) ;
132
142
}
133
143
0 commit comments