Skip to content

Commit 09f6bc9

Browse files
committed
Symlink .next build output instead of copying
Replaces copying the .next directory with creating a symlink to preserve internal symlinks, improving compatibility with pnpm. Also removes the root next.config.mjs and adds .next to .gitignore.
1 parent 1e610e6 commit 09f6bc9

3 files changed

Lines changed: 5 additions & 14 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ next-env.d.ts
3434

3535
# fumadocs
3636
.source
37+
.next

next.config.mjs

Lines changed: 0 additions & 11 deletions
This file was deleted.

packages/cli/src/commands/build.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,13 @@ export function registerBuildCommand(cli) {
6161
const destNext = path.join(process.cwd(), '.next');
6262

6363
if (fs.existsSync(srcNext) && srcNext !== destNext) {
64-
console.log(`\nMoving .next build output to ${destNext}...`);
64+
console.log(`\nLinking .next build output to ${destNext}...`);
6565
if (fs.existsSync(destNext)) {
6666
fs.rmSync(destNext, { recursive: true, force: true });
6767
}
68-
fs.cpSync(srcNext, destNext, { recursive: true });
69-
console.log(`Build successfully output to: ${destNext}`);
68+
// Use symlink instead of copy to preserve internal symlinks in .next (pnpm support)
69+
fs.symlinkSync(srcNext, destNext, 'dir');
70+
console.log(`Build successfully linked to: ${destNext}`);
7071
} else {
7172
console.log(`\nNo 'out' directory generated in ${src}.`);
7273
console.log(`This is expected if 'output: export' is disabled.`);

0 commit comments

Comments
 (0)