31 lines
802 B
TypeScript
31 lines
802 B
TypeScript
import { promises as fs } from "fs";
|
|
import * as util from "../util";
|
|
import sass, { Result as SassResult } from "node-sass";
|
|
import ejs from "ejs";
|
|
|
|
function renderSass(data: string, minify = false): Promise<SassResult> {
|
|
return new Promise((resolve, reject) => {
|
|
sass.render({
|
|
data: data,
|
|
outputStyle: minify ? "compressed" : "expanded"
|
|
}, (error, result) => {
|
|
if (error) reject(error);
|
|
else resolve(result);
|
|
});
|
|
});
|
|
}
|
|
|
|
async function generate(theme: string) {
|
|
const filename = `site/css/${theme}.scss`;
|
|
|
|
let sass = (await fs.readFile(filename)).toString();
|
|
sass = util.render(sass, {}, filename);
|
|
const result = await renderSass(sass);
|
|
|
|
util.write(`css/${theme}.css`, result.css);
|
|
}
|
|
|
|
export default async function css() {
|
|
await generate("light");
|
|
await generate("dark");
|
|
} |