2026-07-13 18:12:33 +00:00
|
|
|
// For copying pages and assets
|
|
|
|
|
|
2026-07-12 13:20:35 +00:00
|
|
|
const fs = require('fs');
|
2026-07-12 12:01:01 +00:00
|
|
|
const path = require('path');
|
|
|
|
|
|
2026-07-12 13:20:35 +00:00
|
|
|
const ROOT = path.join(__dirname, '..');
|
|
|
|
|
const SRC = path.join(ROOT, 'source');
|
|
|
|
|
const DEST = path.join(ROOT, 'build', 'app');
|
2026-07-12 12:01:01 +00:00
|
|
|
|
2026-07-12 13:20:35 +00:00
|
|
|
// Server-side dirs or dirs with their own build step — skip
|
|
|
|
|
const SKIP = new Set(['server', 'locale-data', 'locales', 'library-ts', 'pages']);
|
2026-07-12 12:01:01 +00:00
|
|
|
|
2026-07-12 13:20:35 +00:00
|
|
|
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)) {
|
2026-07-12 12:01:01 +00:00
|
|
|
if (file.endsWith('.html')) {
|
2026-07-12 13:20:35 +00:00
|
|
|
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));
|
2026-07-12 12:01:01 +00:00
|
|
|
}
|
|
|
|
|
}
|