/
config.js
58 lines (54 loc) · 1.38 KB
/
config.js
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
55
56
57
58
const StyleDictionary = require("style-dictionary");
module.exports = {
// Define your input files here
source: [
// This will search for all JSON files in the `tokens` directory and its subdirectories
"./tokens/**/*.json",
"!./tokens/figma_styles.json",
],
// Define your output formats here
platforms: {
// Example output format for generating a CSS file
css: {
transformGroup: "css",
buildPath: "./dist/",
files: [
{
destination: "tokens.css",
format: "css/variables",
options: {
// Look here 👇
outputReferences: true,
},
},
],
},
javascript: {
transformGroup: "js",
buildPath: "./dist/",
files: [
{
destination: "tokens.js",
format: "javascript/module-flat",
options: {
// Look here 👇
outputReferences: true,
},
},
],
},
},
transforms: [
// Example transform for converting color values from HEX to RGBA
{
name: "color/rgba",
type: "value",
matcher: (prop) => prop.attributes.category === "color",
transformer: (prop) => {
const { r, g, b } = StyleDictionary.properties.color.toRgb(prop.value);
const a = prop.attributes.alpha;
return `rgba(${r}, ${g}, ${b}, ${a})`;
},
},
],
};