fix: copy CSS/SVG static assets in build step; fix mkdirSync to use recursive

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Rokojori 2026-07-12 15:20:35 +02:00
parent 0b91bdcc90
commit f8723c87ff
3 changed files with 34 additions and 9 deletions

View File

@ -1,13 +1,38 @@
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const src = path.join(__dirname, '..', 'source', 'pages'); const ROOT = path.join(__dirname, '..');
const dest = path.join(__dirname, '..', 'build', 'app'); const SRC = path.join(ROOT, 'source');
const DEST = path.join(ROOT, 'build', 'app');
fs.mkdirSync(dest, { recursive: true }); // Server-side dirs or dirs with their own build step — skip
const SKIP = new Set(['server', 'locale-data', 'locales', 'library-ts', 'pages']);
for (const file of fs.readdirSync(src)) { function copyStatic(src, dest) {
if (file.endsWith('.html')) { fs.mkdirSync(dest, { recursive: true });
fs.copyFileSync(path.join(src, file), path.join(dest, file)); for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);
if (entry.isDirectory()) {
copyStatic(srcPath, destPath);
} else if (!entry.name.endsWith('.ts')) {
fs.copyFileSync(srcPath, destPath);
}
}
}
// Copy HTML pages
const pagesDir = path.join(SRC, 'pages');
fs.mkdirSync(DEST, { recursive: true });
for (const file of fs.readdirSync(pagesDir)) {
if (file.endsWith('.html')) {
fs.copyFileSync(path.join(pagesDir, file), path.join(DEST, file));
}
}
// Copy all non-TS static assets (CSS, SVG, etc.) from frontend source dirs
for (const entry of fs.readdirSync(SRC, { withFileTypes: true })) {
if (entry.isDirectory() && !SKIP.has(entry.name)) {
copyStatic(path.join(SRC, entry.name), path.join(DEST, entry.name));
} }
} }

View File

@ -3,7 +3,7 @@ import path from 'path';
import { randomUUID } from 'crypto'; import { randomUUID } from 'crypto';
const DATA_DIR = path.join(__dirname, '..', '..', 'build', 'data', 'db'); const DATA_DIR = path.join(__dirname, '..', '..', 'build', 'data', 'db');
if (!fs.existsSync(DATA_DIR)) fs.mkdirSync(DATA_DIR); if (!fs.existsSync(DATA_DIR)) fs.mkdirSync(DATA_DIR, { recursive: true });
export interface User { export interface User {
id: string; id: string;

View File

@ -2,7 +2,7 @@ import fs from 'fs';
import path from 'path'; import path from 'path';
const STORAGE_DIR = path.join(__dirname, '..', '..', 'build', 'data', 'storage'); const STORAGE_DIR = path.join(__dirname, '..', '..', 'build', 'data', 'storage');
if (!fs.existsSync(STORAGE_DIR)) fs.mkdirSync(STORAGE_DIR); if (!fs.existsSync(STORAGE_DIR)) fs.mkdirSync(STORAGE_DIR, { recursive: true });
const INITIAL_HTML = `<!DOCTYPE html> const INITIAL_HTML = `<!DOCTYPE html>
<html lang="en"> <html lang="en">