8000 fix: move cache assets instead of copying them · opennextjs/opennextjs-aws@9a40cdb · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9a40cdb

Browse files
committed
fix: move cache assets instead of copying them
fixes parts of #822
1 parent ab492ca commit 9a40cdb

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

packages/open-next/src/build/createAssets.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,22 @@ export function createCacheAssets(options: buildHelper.BuildOptions) {
9292
".next/standalone",
9393
packagePath,
9494
);
95+
9596
const outputPath = path.join(outputDir, "cache", buildId);
97+
98+
// Ensure output directory exists
99+
fs.mkdirSync(outputPath, { recursive: true });
100+
96101
[".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+
});
100111

101112
// Remove non-cache files
102113
const htmlPages = buildHelper.getHtmlPages(dotNextPath);

0 commit comments

Comments
 (0)
0