mirror of
https://github.com/resend/react-email.git
synced 2026-09-14 14:18:02 +08:00
a407b5a820
Co-authored-by: gabriel miranda <gabrielmfern@outlook.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: João Melo <jopcmelo@Joaos-MacBook-Pro.local> Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> Co-authored-by: João Melo <joaopcm@users.noreply.github.com>
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
import {
|
|
cpSync,
|
|
mkdirSync,
|
|
readdirSync,
|
|
readFileSync,
|
|
statSync,
|
|
writeFileSync,
|
|
} from 'node:fs';
|
|
import { dirname, join, relative, sep } from 'node:path';
|
|
import postcss from 'postcss';
|
|
import postcssImport from 'postcss-import';
|
|
|
|
const src = 'src';
|
|
const dist = 'dist';
|
|
|
|
const themeProcessor = postcss([postcssImport()]);
|
|
|
|
async function processTheme(full: string, dest: string) {
|
|
const css = readFileSync(full, 'utf8');
|
|
const result = await themeProcessor.process(css, { from: full, to: dest });
|
|
mkdirSync(dirname(dest), { recursive: true });
|
|
writeFileSync(dest, result.css);
|
|
console.log(`processed ${relative(src, full)}`);
|
|
}
|
|
|
|
async function main() {
|
|
const themeFiles: { full: string; dest: string }[] = [];
|
|
|
|
function walk(dir: string) {
|
|
for (const entry of readdirSync(dir)) {
|
|
const full = join(dir, entry);
|
|
if (statSync(full).isDirectory()) {
|
|
walk(full);
|
|
} else if (entry.endsWith('.css')) {
|
|
const rel = relative(src, full).split(sep).join('/');
|
|
const dest = join(dist, rel);
|
|
if (rel.startsWith('ui/themes/')) {
|
|
themeFiles.push({ full, dest });
|
|
} else {
|
|
cpSync(full, dest, { recursive: true });
|
|
console.log(`copied ${rel}`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
walk(src);
|
|
|
|
for (const { full, dest } of themeFiles) {
|
|
await processTheme(full, dest);
|
|
}
|
|
}
|
|
|
|
main();
|