forked from nl-design-system/themes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
style-dictionary-config.js
80 lines (77 loc) · 1.85 KB
/
style-dictionary-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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const stringSort = (a, b) => (a === b ? 0 : a > b ? 1 : -1);
const sortByName = (a, b) => stringSort(a.name, b.name);
const createConfig = ({ selector, source = ['src/**/*.tokens.json'] }) => ({
format: {
'json/list': function ({ dictionary }) {
return JSON.stringify(dictionary.allTokens.sort(sortByName), null, ' ');
},
},
source,
platforms: {
js: {
transforms: ['attribute/cti', 'name/cti/camel', 'color/hsl-4'],
buildPath: 'dist/',
files: [
{
destination: 'index.js',
format: 'javascript/es6',
},
],
},
json: {
transforms: ['attribute/cti', 'name/cti/camel', 'color/hsl-4'],
buildPath: 'dist/',
files: [
{
destination: 'tokens.json',
format: 'json',
},
{
destination: 'index.json',
format: 'json/list',
},
],
},
css: {
transforms: ['attribute/cti', 'name/cti/kebab', 'color/hsl-4'],
buildPath: 'dist/',
files: [
{
destination: 'design-tokens.css',
format: 'css/variables',
options: {
selector,
outputReferences: true,
},
},
],
},
scss: {
transforms: ['attribute/cti', 'name/cti/kebab', 'color/hsl-4'],
buildPath: 'dist/',
files: [
{
destination: 'index.scss',
format: 'scss/variables',
options: {
outputReferences: true,
},
},
],
},
less: {
transforms: ['attribute/cti', 'name/cti/kebab', 'color/hsl-4'],
buildPath: 'dist/',
files: [
{
destination: 'index.less',
format: 'less/variables',
options: {
outputReferences: true,
},
},
],
},
},
});
module.exports = { createConfig };