You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
click I "#8-format-the-tokens-into-files" "Explanation about formatting tokens to output files"
42
+
click J "#9-run-actions" "Explanation about running actions"
43
+
end
44
+
global --> platform --> files
45
+
```
10
46
11
47
Let's take a closer look into each of these steps.
12
48
@@ -18,37 +54,35 @@ Style Dictionary is a configuration based framework, you tell it what to do in a
18
54
19
55
In your [config](/reference/config) file can define `include` and `source`, which are arrays of file path globs. These tell Style Dictionary where to find your token files. You can have them anywhere and in any folder structure as long as you tell Style Dictionary where to find them.
20
56
21
-
If there are [custom parsers](/reference/hooks/parsers) defined and applied in the config, Style Dictionary will run those on files the applied parsers match.
57
+
## 3. Parse token files
58
+
59
+
If there are [custom parsers](/reference/hooks/parsers) defined and applied in the config, Style Dictionary will run those on files the applied parsers match. For JSON or JavaScript token files, those are parsed automatically through built-in parsers.
22
60
23
-
## 3. Deep merge token files
61
+
## 4. Deep merge token files
24
62
25
63
Style Dictionary takes all the files it found and performs a deep merge. This allows you to split your token files in any way you like, without worrying about accidentally overriding groups of tokens. This gives Style Dictionary a single, complete token object to work from.
26
64
27
-
## 4. Run preprocessors over the dictionary
65
+
## 5. Run preprocessors over the dictionary
28
66
29
67
Allows users to configure [custom preprocessors](/reference/hooks/preprocessors), to process the merged dictionary as a whole, rather than per token file individually.
30
68
These preprocessors have to be applied in the config, either on a global or platform level.
69
+
Platform level preprocessors run once you get/export/format/build a platform, at the very start.
31
70
32
-
## 5. Iterate over the platforms
33
-
34
-
For each platform defined in your [config](/reference/config), Style Dictionary will do a few steps to get it ready to be consumed on that platform. You don't need to worry about one platform affecting another because everything that happens in a platform is non-destructive.
35
-
Platform-applied preprocessors run now instead of beforehand in step 4.
36
-
37
-
## 5a. Transform the tokens
71
+
## 6. Transform the tokens
38
72
39
73
Style Dictionary now traverses over the whole token object and looks for design tokens. It does this by looking for anything with a `value` key. When it comes across a design token, it then performs all the [transforms](/reference/hooks/transforms) defined in your [config](/reference/config) in order.
40
74
41
75
Value transforms, transforms that modify a token's value, are skipped if the token references another token. Starting in 3.0, you can define a [transitive transform](/reference/hooks/transforms#transitive-transforms) that will transform a value that references another token after that reference has been resolved.
42
76
43
-
## 5b. Resolve aliases / references to other values
77
+
## 7. Resolve aliases / references to other values
44
78
45
79
After all the tokens have been transformed, it then does another pass over the token object looking for aliases, which look like `"{size.font.base.value}"`. When it finds these, it then replaces the reference with the transformed value. Because Style Dictionary merges all token files into a single object, aliases can be in any token file and still work.
46
80
47
-
## 5c. Format the tokens into files
81
+
## 8. Format the tokens into files
48
82
49
83
Now all the design tokens are ready to be written to a file. Style Dictionary takes the whole transformed and resolved token object and for each file defined in the platform it [formats](/reference/hooks/formats) the token object and write the output to a file. Internally, Style Dictionary creates a flat array of all the design tokens it finds in addition to the token object. This is how you can output a flat SCSS variables file.
50
84
51
-
## 5d. Run actions
85
+
## 9. Run actions
52
86
53
87
[Actions](/reference/hooks/actions) are custom code that run in a platform after the files are generated. They are useful for things like copying assets to specific build directories or generating images.
// Call the plugin initialization function inside the `plugins` array
8
+
pluginLanguageClass(),
9
+
],
10
+
styleOverrides: {
11
+
textMarkers: {
12
+
defaultLuminance: ['15%','85%'],
13
+
},
14
+
},
15
+
},
4
16
title: 'Style Dictionary',
5
17
description:
6
18
'Export your Design Tokens to any platform. iOS, Android, CSS, JS, HTML, sketch files, style documentation, or anything you can think of. Forward-compatible with Design Token Community Group spec.',
0 commit comments