本地 RAG 知识库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

27 lines
780 B

/**
* Vite build 后自动将产物复制到 Spring Boot 静态资源目录。
* 由 npm postbuild 钩子触发。
*/
import { cpSync, existsSync, readdirSync, rmSync } from 'node:fs';
import { join } from 'node:path';
const DIST = 'dist';
const TARGET = '../src/main/resources/static';
// 1. 清理上一次 Vite 构建的产物(保留 sdk/ 目录)
if (existsSync(TARGET)) {
for (const entry of readdirSync(TARGET)) {
if (entry !== 'sdk') {
rmSync(join(TARGET, entry), { recursive: true, force: true });
}
}
}
// 2. 复制新构建产物
if (existsSync(DIST)) {
cpSync(DIST, TARGET, { recursive: true });
console.log('✓ 已复制到', TARGET);
} else {
console.error('✗ dist 目录不存在,请先执行 vite build');
process.exit(1);
}