Skip to content
Discussion options

You must be logged in to vote

with Next15, colors could be extracted as an .ts file,
So I just made a "predev" scripts to make theme as static css file.

"scripts": {
    "predev": "tsx ./scripts/predev.mts",
    "dev": "next dev"
}
import fs from 'fs';

import { Colors } from '../app/lib/style/colors';

// write colors as css
const colors = Object.entries(Colors)
  .map(([name, value]) => `--colors-${name}: ${value};`)
  .join('\n');
const css = `:root {\n${colors}\n}`;

// write css to file. make sure './build' is added on `.gitignore`
fs.mkdirSync('./build/style', { recursive: true });
fs.writeFileSync('./build/style/colors.css', css);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by FourwingsY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant