File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
packages/open-next/src/build Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -92,11 +92,22 @@ export function createCacheAssets(options: buildHelper.BuildOptions) {
92
92
".next/standalone" ,
93
93
packagePath ,
94
94
) ;
95
+
95
96
const outputPath = path . join ( outputDir , "cache" , buildId ) ;
97
+
98
+ // Ensure output directory exists
99
+ fs . mkdirSync ( outputPath , { recursive : true } ) ;
100
+
96
101
[ ".next/server/pages" , ".next/server/app" ]
97
- . map ( ( dir ) => path . join ( dotNextPath , dir ) )
98
- . filter ( fs . existsSync )
99
- . forEach ( ( dir ) => fs . cpSync ( dir , outputPath , { recursive : true } ) ) ;
102
+ . map ( ( dir ) => path . join ( dotNextPath , dir ) )
103
+ . filter ( fs . existsSync )
104
+ . forEach ( ( dir ) => {
105
+ const dirName = path . basename ( dir ) ;
106
+ const targetPath = path . join ( outputPath , dirName ) ;
107
+
108
+ // Rename the directory instead of copying to avoid blowing up the build size
109
+ fs . renameSync ( dir , targetPath ) ;
110
+ } ) ;
100
111
101
112
// Remove non-cache files
102
113
const htmlPages = buildHelper . getHtmlPages ( dotNextPath ) ;
You can’t perform that action at this time.
0 commit comments