-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsd.config.ts
54 lines (47 loc) · 1.49 KB
/
sd.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import StyleDictionary from "style-dictionary"
import { formats, transformGroups } from "style-dictionary/enums"
const THEMES = ["light", "dark"]
const PREFIX = "sd"
const createStyleDictionaryConfig = (theme: string) => {
const isLight = theme === "light"
const src = isLight ? `!(*.${THEMES.join("|*.")})` : `*.${theme}`
return {
source: [`tokens/${src}.{json,json5}`],
platforms: {
css: {
transformGroup: transformGroups.css,
prefix: PREFIX,
buildPath: "dist/css/",
files: [
{
destination: `variables.${theme}.css`,
format: formats.cssVariables,
options: {
selector: `.${PREFIX}--theme-${theme} { color-scheme: ${theme}; }\n\n:root, :host, .${PREFIX}--theme-${theme}`,
outputReferences: true,
},
},
],
},
json: {
transformGroup: transformGroups.web,
prefix: PREFIX,
buildPath: "dist/json/",
files: [
{ destination: `properties.${theme}.json`, format: formats.json },
],
},
},
}
}
const buildThemes = (async () => {
console.log("Build started...")
console.log("\n==============================================")
for (const theme of THEMES) {
const sd = new StyleDictionary(createStyleDictionaryConfig(theme))
await sd.buildAllPlatforms()
}
console.log("\n==============================================")
console.log("\nBuild completed!")
})()
export default buildThemes