import { PATH_SOURCE, PATH_DESTINATION_THEME, PATH_DESTINATION_PUBLIC } from '../constants'; import StyleDictionaryPackage from 'style-dictionary'; import { ThemeName, ThemeNames } from '@lendi-ui/commons/utils'; const themes = [ThemeNames.Aussie, ThemeNames.Lendi, ThemeNames.LendiNext, ThemeNames.Domain]; const getConfigForTheme = (theme: ThemeName) => { return { source: [`${PATH_SOURCE}/global/*.ts`, `${PATH_SOURCE}/theme/${theme}/**/*.ts`], platforms: { components: { transformGroup: 'css', files: [ { format: 'json/nested', destination: `${PATH_DESTINATION_THEME}/theme/${theme}/token.json`, options: { outputReferences: true, }, }, { format: 'css/variables', destination: `${PATH_DESTINATION_THEME}/theme/${theme}/token.css`, options: { outputReferences: true, }, }, ], }, web: { transformGroup: 'css', files: [ { format: 'json/nested', destination: `${PATH_DESTINATION_PUBLIC}/latest/${theme}.json`, options: { outputReferences: true, }, }, { format: 'css/variables', destination: `${PATH_DESTINATION_PUBLIC}/latest/${theme}.css`, options: { outputReferences: true, }, }, ], }, }, }; }; export const buildStyledComponents = () => { console.log('\n=============================================='); console.log(`\nProcessing: [Themes]`); themes.map(function (theme) { console.log(`\nProcessing: [${theme}]`); const StyleDictionary = StyleDictionaryPackage.extend(getConfigForTheme(theme)); StyleDictionary.buildAllPlatforms(); console.log('\nEnd processing'); }); };