mirror of
https://github.com/LiuYuYang01/ThriveX-Blog.git
synced 2026-09-03 06:24:24 +08:00
1. 在Dockerfile中新增复制公共静态资源的逻辑,确保应用在构建时包含必要的文件。 2. 在package.json中添加postbuild脚本,自动化复制独立资产的过程,提升构建效率。
19 lines
625 B
JavaScript
19 lines
625 B
JavaScript
import { copyFileSync, existsSync, mkdirSync, readdirSync, statSync } from 'node:fs';
|
|
import { dirname, join } from 'node:path';
|
|
|
|
function copy(src, dest) {
|
|
if (statSync(src).isDirectory()) {
|
|
mkdirSync(dest, { recursive: true });
|
|
for (const name of readdirSync(src)) copy(join(src, name), join(dest, name));
|
|
return;
|
|
}
|
|
mkdirSync(dirname(dest), { recursive: true });
|
|
copyFileSync(src, dest);
|
|
}
|
|
|
|
const standalone = '.next/standalone';
|
|
if (!existsSync(standalone)) process.exit(0);
|
|
|
|
copy('.next/static', join(standalone, '.next/static'));
|
|
if (existsSync('public')) copy('public', join(standalone, 'public'));
|