-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-tokens.cjs
62 lines (58 loc) · 1.63 KB
/
build-tokens.cjs
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
59
60
61
62
const StyleDictionary = require('style-dictionary');
const styleDictionaryConfig = {
log: 'warn',
source: ['src/tokens/**/*.+(js|json)'],
platforms: {
web: {
transformGroup: 'custom/transform-group/css',
buildPath: 'src/compiled/css/',
files: [
{
destination: 'tokens.css',
format: 'css/variables',
},
],
},
scss: {
transformGroup: 'custom/transform-group/css',
buildPath: 'src/compiled/scss/',
files: [
{
destination: '_tokens.scss',
format: 'scss/variables',
},
],
},
js: {
transformGroup: 'custom/transform-group/css',
buildPath: 'src/compiled/js/',
files: [
{
destination: 'tokens.json',
format: 'json',
},
{
destination: 'breakpoints.js',
format: 'javascript/module',
filter: { attributes: { category: 'size', type: 'breakpoint' } },
},
],
},
},
};
/**
* Custom Transform Group: CSS
* This is a modified version of the CSS transform group without the time,
* size, or icon transformations and using our custom CSS color transform.
* We also use it for JSON.
*/
StyleDictionary.registerTransformGroup({
name: 'custom/transform-group/css',
transforms: ['attribute/cti', 'name/cti/kebab', 'color/css'],
});
// APPLY THE CONFIGURATION
// IMPORTANT: the registration of custom transforms
// needs to be done _before_ applying the configuration
const StyleDictionaryExtended = StyleDictionary.extend(styleDictionaryConfig);
// BUILD ALL THE PLATFORMS
StyleDictionaryExtended.buildAllPlatforms();