Skip to content

Commit 0c0cce3

Browse files
committed
Update build.mjs
1 parent 9bee946 commit 0c0cce3

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

packages/cli/src/commands/build.mjs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,21 @@ export function registerBuildCommand(cli) {
5656
fs.cpSync(src, dest, { recursive: true });
5757
console.log(`Build successfully output to: ${dest}`);
5858
} else {
59-
console.log(`\nNo 'out' directory generated in ${src}.`);
60-
console.log(`This is expected if 'output: export' is disabled.`);
59+
// Check for .next directory (dynamic build)
60+
const srcNext = path.join(nextAppDir, '.next');
61+
const destNext = path.join(process.cwd(), '.next');
62+
63+
if (fs.existsSync(srcNext) && srcNext !== destNext) {
64+
console.log(`\nMoving .next build output to ${destNext}...`);
65+
if (fs.existsSync(destNext)) {
66+
fs.rmSync(destNext, { recursive: true, force: true });
67+
}
68+
fs.cpSync(srcNext, destNext, { recursive: true });
69+
console.log(`Build successfully output to: ${destNext}`);
70+
} else {
71+
console.log(`\nNo 'out' directory generated in ${src}.`);
72+
console.log(`This is expected if 'output: export' is disabled.`);
73+
}
6174
}
6275
}
6376
process.exit(code);

0 commit comments

Comments
 (0)