feat: 更新构建流程,添加 API 构建脚本和 SQL 文件复制脚本
- 修改 package.json,更新构建命令,添加 postbuild 脚本以复制 init.sql 文件。 - 新增 scripts/build-api.mjs,使用 esbuild 构建 API 代码。 - 新增 scripts/copy-init-sql.mjs,复制数据库初始化 SQL 文件到构建输出目录。 - 在 SubjectSelectionPage 组件中添加 totalScore 属性,增加历史最高分状态显示功能。 - 在 ExamSubjectPage 和 QuestionManagePage 中优化判断题答案处理逻辑。 - 在 OptionList 组件中将判断题选项文本从 'T' 和 'F' 改为 '对' 和 '错'。 - 在 QuizFooter 组件中调整样式,增加按钮和文本的可读性。 - 新增用户默认组测试用例,验证新用户创建后自动加入“全体用户”系统组。 - 新增 tsconfig.api.json,配置 API 相关 TypeScript 编译选项。 - 移除 vite.config.ts 中的 global 定义。
This commit is contained in:
35
scripts/build-api.mjs
Normal file
35
scripts/build-api.mjs
Normal file
@@ -0,0 +1,35 @@
|
||||
import { build } from 'esbuild';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
const projectRoot = process.cwd();
|
||||
const pkgPath = path.join(projectRoot, 'package.json');
|
||||
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
||||
|
||||
const dependencies = Object.keys(pkg.dependencies ?? {});
|
||||
const optionalDependencies = Object.keys(pkg.optionalDependencies ?? {});
|
||||
const peerDependencies = Object.keys(pkg.peerDependencies ?? {});
|
||||
|
||||
const externals = Array.from(
|
||||
new Set([
|
||||
...dependencies,
|
||||
...optionalDependencies,
|
||||
...peerDependencies,
|
||||
// also keep these as runtime externals
|
||||
'sqlite3',
|
||||
]),
|
||||
);
|
||||
|
||||
await build({
|
||||
entryPoints: ['api/server.ts'],
|
||||
outfile: 'dist/api/server.js',
|
||||
bundle: true,
|
||||
platform: 'node',
|
||||
format: 'esm',
|
||||
target: ['node20'],
|
||||
sourcemap: true,
|
||||
logLevel: 'info',
|
||||
external: externals,
|
||||
});
|
||||
|
||||
console.log('Built backend -> dist/api/server.js');
|
||||
Reference in New Issue
Block a user