@@ -24,14 +24,14 @@ Generate `tailwind.config.js` by setting type to `all`.
2424See [ Creating each theme file] ( https://github.com/nado1001/sd-tailwindcss-transformer#creating-each-theme-file ) if you wish to customize the configuration file with [ plugin functions] ( https://tailwindcss.com/docs/plugins ) , etc.
2525
2626``` js
27- const StyleDictionaryModule = require ( ' style-dictionary' )
28- const { makeSdTailwindConfig } = require ( ' sd-tailwindcss-transformer' )
29-
30- const StyleDictionary = StyleDictionaryModule . extend (
31- makeSdTailwindConfig ({ type: ' all' })
32- )
33-
34- StyleDictionary .buildAllPlatforms ()
27+ import StyleDictionary from ' style-dictionary' ;
28+ import { makeSdTailwindConfig } from ' sd-tailwindcss-transformer' ;
29+
30+ const styleDictionaryTailwind = new StyleDictionary (
31+ makeSdTailwindConfig ({ type: ' all' }),
32+ );
33+ await styleDictionaryTailwind . hasInitialized ;
34+ await styleDictionaryTailwind .buildAllPlatforms ();
3535```
3636
3737Output:
@@ -68,18 +68,21 @@ Create an object for each theme, assuming that various customizations will be ma
6868Import and use the created files in ` tailwind.config.js ` .
6969
7070``` js
71- const StyleDictionaryModule = require ( ' style-dictionary' )
72- const { makeSdTailwindConfig } = require ( ' sd-tailwindcss-transformer' )
71+ import StyleDictionary from ' style-dictionary' ;
72+ import { makeSdTailwindConfig } from ' sd-tailwindcss-transformer' ;
7373
74- const types = [' colors' , ' fontSize' ]
74+ const types = [' colors' , ' fontSize' ];
7575
76- types . map (( type ) => {
77- const StyleDictionary = StyleDictionaryModule . extend (
78- makeSdTailwindConfig ({ type })
79- )
76+ for ( const type of types) {
77+ let tailwindConfig = makeSdTailwindConfig ({
78+ type,
79+ });
8080
81- StyleDictionary .buildAllPlatforms ()
82- })
81+ const styleDictionaryTailwind = new StyleDictionary (tailwindConfig);
82+
83+ await styleDictionaryTailwind .hasInitialized ;
84+ await styleDictionaryTailwind .buildAllPlatforms ();
85+ }
8386```
8487
8588Output:
@@ -110,30 +113,33 @@ CSS custom variables can be used by setting isVariables to `true`.
110113In this case, a CSS file must also be generated.
111114
112115``` js
113- const StyleDictionaryModule = require ( ' style-dictionary' )
114- const { makeSdTailwindConfig } = require ( ' sd-tailwindcss-transformer' )
116+ import StyleDictionary from ' style-dictionary' ;
117+ import { makeSdTailwindConfig } from ' sd-tailwindcss-transformer' ;
115118
116119const sdConfig = makeSdTailwindConfig ({
117- type: ' all' ,
118- isVariables: true
119- })
120+ type: ' all' ,
121+ isVariables: true ,
122+ });
120123
121124sdConfig .platforms [' css' ] = {
122- transformGroup: ' css' ,
123- buildPath: ' ./styles/' ,
124- files: [
125- {
126- destination: ' tailwind.css' ,
127- format: ' css/variables' ,
128- options: {
129- outputReferences: true
130- }
131- }
132- ]
133- }
134-
135- const StyleDictionary = StyleDictionaryModule .extend (sdConfig)
136- StyleDictionary .buildAllPlatforms ()
125+ transformGroup: ' css' ,
126+ buildPath: ' ./styles/' ,
127+ files: [
128+ {
129+ destination: ' tailwind.css' ,
130+ format: ' css/variables' ,
131+ options: {
132+ outputReferences: true ,
133+ },
134+ },
135+ ],
136+ };
137+
138+ const styleDictionaryTailwind = new StyleDictionary (
139+ makeSdTailwindConfig ({ type: ' all' }),
140+ );
141+ await styleDictionaryTailwind .hasInitialized ;
142+ await styleDictionaryTailwind .buildAllPlatforms ();
137143```
138144
139145Output:
0 commit comments