Load the Sokko TCG styles with the cards route
Some checks failed
Validate and deploy Sokko G / validate (push) Failing after 20m30s
Validate and deploy Sokko G / deploy (push) Has been skipped

The cards and Expeditions sheets were a quarter of the CSS every visitor
downloaded. cards-route.scss now bundles them with CardsPage; only the
menu icon stays in main.scss. The sheets that followed them in main.scss
(checklist, NDS attributes, responsive) are re-emitted after them so
equal-specificity rules keep the same winner: the common sheet without
them plus the route sheet rebuilds the previous CSS byte for byte, and a
test keeps the list in step with main.scss. Common CSS goes from 94 243
to 69 413 bytes gzip and its budget from 100 000 to 75 000.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-21 17:23:14 +01:00
parent d2ef3b098c
commit a52f89e9d5
9 changed files with 70 additions and 15 deletions

View file

@ -128,3 +128,20 @@ test("large sass files stay split by stable responsibility", async () => {
assert.ok(countLines(source) <= 300, `${path} should stay scoped to one responsibility`);
}
});
test("Sokko TCG styles load with their route and keep the single-sheet cascade", async () => {
const root = "website/src/styles";
const uses = (source) => [...source.matchAll(/^@use "([^"]+)";/gm)].map((match) => match[1]);
const main = uses(await readFile(`${root}/main.scss`, "utf8"));
const route = uses(await readFile(`${root}/cards-route.scss`, "utf8"));
const cardSheets = route.filter((name) => name.startsWith("nebula-"));
assert.deepEqual(cardSheets, ["nebula-cards", "nebula-expeditions", "nebula-expedition-destinations", "nebula-expedition-loadout", "nebula-expedition-journey"]);
assert.ok(cardSheets.every((name) => !main.includes(name)), "main.scss must not load the Sokko TCG sheets");
// La feuille de route ré-émet, dans le même ordre, toutes les feuilles qui suivaient les cartes dans main.scss.
const after = main.slice(main.indexOf("nebula-cards-nav") + 1);
assert.ok(after.length > 0);
assert.deepEqual(route.slice(cardSheets.length), after);
assert.match(await readFile("website/src/features/cards/CardsPage.jsx", "utf8"), /^import "\.\.\/\.\.\/styles\/cards-route\.scss";$/m);
// L'icône du menu s'affiche sur toutes les pages : elle reste dans la feuille commune.
assert.doesNotMatch(await readFile(`${root}/_nebula-cards.scss`, "utf8"), /\.nav-icon-cards/);
});