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:
parent
0b91bdcc90
commit
f8723c87ff
|
|
@ -1,13 +1,38 @@
|
|||
const fs = require('fs');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const src = path.join(__dirname, '..', 'source', 'pages');
|
||||
const dest = path.join(__dirname, '..', 'build', 'app');
|
||||
const ROOT = path.join(__dirname, '..');
|
||||
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)) {
|
||||
if (file.endsWith('.html')) {
|
||||
fs.copyFileSync(path.join(src, file), path.join(dest, file));
|
||||
function copyStatic(src, dest) {
|
||||
fs.mkdirSync(dest, { recursive: true });
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import path from 'path';
|
|||
import { randomUUID } from 'crypto';
|
||||
|
||||
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 {
|
||||
id: string;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import fs from 'fs';
|
|||
import path from 'path';
|
||||
|
||||
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>
|
||||
<html lang="en">
|
||||
|
|
|
|||
Loading…
Reference in New Issue