Skip to content

Commit 14b9527

Browse files
committed
在构建命令中添加用户配置和公共资产的复制功能
1 parent 5d6b607 commit 14b9527

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/cli/src/commands/build.mjs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,21 @@ export function registerBuildCommand(cli) {
2424
nextAppDir = path.resolve(__dirname, '../../../site');
2525
}
2626

27+
// Copy user config and assets to nextAppDir
28+
const userConfigPath = path.resolve(process.cwd(), 'objectdocs.json');
29+
if (fs.existsSync(userConfigPath)) {
30+
console.log(` Copying config from ${userConfigPath}`);
31+
fs.cpSync(userConfigPath, path.join(nextAppDir, 'objectdocs.json'));
32+
}
2733

2834
const userPublicPath = path.resolve(process.cwd(), 'public');
2935
if (fs.existsSync(userPublicPath)) {
30-
fs.cpSync(userPublicPath, path.join(nextAppDir, 'public'), { recursive: true });
36+
console.log(` Copying public assets from ${userPublicPath}`);
37+
const targetPublicDir = path.join(nextAppDir, 'public');
38+
if (!fs.existsSync(targetPublicDir)) {
39+
fs.mkdirSync(targetPublicDir, { recursive: true });
40+
}
41+
fs.cpSync(userPublicPath, targetPublicDir, { recursive: true, force: true });
3142
}
3243

3344
console.log(`Building docs site...`);

0 commit comments

Comments
 (0)