Skip to content

Commit fc45695

Browse files
committed
feat: enhance post-build script to conditionally copy database file
1 parent 940c434 commit fc45695

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

packages/ui/next.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import type { NextConfig } from "next";
22

33
const nextConfig: NextConfig = {
44
output: 'standalone',
5+
// Exclude SQLite database from file tracing to avoid ENOENT errors
6+
// The database is created at runtime or during seed
7+
outputFileTracingExcludes: {
8+
'*': ['**/*.db', '**/leanspec.db'],
9+
},
510
};
611

712
export default nextConfig;

packages/ui/scripts/post-build.mjs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env node
2-
import { cp } from 'node:fs/promises';
2+
import { cp, access, constants } from 'node:fs/promises';
33
import { join, dirname } from 'node:path';
44
import { fileURLToPath } from 'node:url';
55

@@ -14,12 +14,25 @@ const staticDest = join(pkgDir, '.next', 'standalone', 'packages', 'ui', '.next'
1414
const publicSrc = join(pkgDir, 'public');
1515
const publicDest = join(pkgDir, '.next', 'standalone', 'packages', 'ui', 'public');
1616

17+
// Copy database file to standalone build
18+
const dbSrc = join(pkgDir, 'leanspec.db');
19+
const dbDest = join(pkgDir, '.next', 'standalone', 'packages', 'ui', 'leanspec.db');
20+
1721
try {
1822
await cp(staticSrc, staticDest, { recursive: true, force: true });
1923
console.log('✓ Copied .next/static to standalone build');
2024

2125
await cp(publicSrc, publicDest, { recursive: true, force: true });
2226
console.log('✓ Copied public assets to standalone build');
27+
28+
// Copy database if it exists (created by db:seed)
29+
try {
30+
await access(dbSrc, constants.F_OK);
31+
await cp(dbSrc, dbDest, { force: true });
32+
console.log('✓ Copied leanspec.db to standalone build');
33+
} catch {
34+
console.log('⚠ No leanspec.db found (skipping database copy)');
35+
}
2336
} catch (error) {
2437
console.error('Failed to copy assets:', error);
2538
process.exit(1);

0 commit comments

Comments
 (0)