mirror of
https://github.com/ancsemi/Haven.git
synced 2026-10-27 09:05:01 +00:00
style.css now only imports the parts in order, after voice.css and music.css as before, so the cascade is unchanged. Each cut sits between top-level rules. Checked twice: the parts (minus the one-line header each got) rebuild the old file byte for byte, and a browser loading the new style.css ends up with the same 3,526 rules, in the same order, as it parses from the old one. The largest part is 1,559 lines. Tests that read style.css now read it with its imports filled in (test/coreCss.js), and the theme contract test names the part each checked rule lives in.
20 lines
739 B
JavaScript
20 lines
739 B
JavaScript
'use strict';
|
||
|
||
// style.css is a list of @import lines; the rules live in the files it
|
||
// imports. Tests that look for a rule read the stylesheet the way a browser
|
||
// does: style.css with every imported file put in place of its @import line.
|
||
|
||
const fs = require('node:fs');
|
||
const path = require('node:path');
|
||
|
||
const CSS_DIR = path.join(__dirname, '..', 'public', 'css');
|
||
|
||
function readCss(file, seen = new Set()) {
|
||
if (seen.has(file)) return '';
|
||
seen.add(file);
|
||
const text = fs.readFileSync(path.join(CSS_DIR, file), 'utf8').replace(/^/, '');
|
||
return text.replace(/@import url\('\/css\/([\w.-]+\.css)(?:\?[^']*)?'\);/g, (_, name) => readCss(name, seen));
|
||
}
|
||
|
||
module.exports = { readCoreCss: () => readCss('style.css'), CSS_DIR };
|