Skip to content

Commit a681010

Browse files
committed
make sure alias tokens are compiled first
1 parent 19023cb commit a681010

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

core/scripts/tokens/index.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,25 @@
4343

4444
console.log('Generating SCSS variables...');
4545

46-
// Separate typography tokens from the rest
47-
const typographyProperties = dictionary.allTokens.filter((prop) => prop.$type === 'typography');
48-
const otherProperties = dictionary.allTokens.filter((prop) => prop.$type !== 'typography');
49-
50-
// Make sure the reused scss variables are defined first, to avoid compilation errors
51-
const sortedProperties = [...otherProperties, ...typographyProperties];
46+
const primitiveProperties = dictionary.allTokens.filter((prop) => prop.path[0] === 'primitives');
47+
const scaleProperties = dictionary.allTokens.filter((prop) => prop.path[0] === 'scale');
48+
const borderProperties = dictionary.allTokens.filter((prop) => prop.path[0] === 'border');
49+
const semanticsProperties = dictionary.allTokens.filter((prop) => prop.path[0] === 'semantics');
50+
const nonPrimitiveScaleBorderSemanticsProperties = dictionary.allTokens.filter(
51+
(prop) => !['primitives', 'scale', 'border', 'semantics'].includes(prop.path[0])
52+
);
53+
const typographyProperties = nonPrimitiveScaleBorderSemanticsProperties.filter((prop) => prop.$type === 'typography');
54+
const otherProperties = nonPrimitiveScaleBorderSemanticsProperties.filter((prop) => prop.$type !== 'typography');
55+
56+
// Order: primitives → semantics → scale → border → other → typography
57+
const sortedProperties = [
58+
...primitiveProperties,
59+
...semanticsProperties,
60+
...scaleProperties,
61+
...borderProperties,
62+
...otherProperties,
63+
...typographyProperties
64+
];
5265

5366
const prefixedVariables = sortedProperties.map((prop) => {
5467
// Remove consecutive repeated words from the token name, like border-border-color

0 commit comments

Comments
 (0)