From f05f3f126af5beb40144e5447a78fa9482e81df9 Mon Sep 17 00:00:00 2001 From: Eugene Date: Thu, 4 Jun 2020 17:35:51 +0300 Subject: [PATCH] feat: use new config format --- src/core-v2/build.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/core-v2/build.ts b/src/core-v2/build.ts index 396a104..4a3f721 100644 --- a/src/core-v2/build.ts +++ b/src/core-v2/build.ts @@ -4,7 +4,7 @@ import cssColorFn from 'css-color-function' import { resolve } from 'path' import { readFileSync, writeFileSync } from 'fs-extra' -import { createWhitepaperConfig } from './whitepaper-config' +import { createStyleDictionaryConfig } from './style-dictionary-config' import { variablesWithPrefix } from './variable-with-prefix' import { loadMappers } from './mappers' import { loadThemes } from './themes' @@ -55,23 +55,23 @@ StyleDictionaryApi.registerAction({ export async function build(config: any): Promise { const normalizedConfig = Array.isArray(config) ? config : [config] for (const themeConfig of normalizedConfig) { - const { mappers, sources, whitepaper } = await loadThemes(themeConfig.themes) - // TODO: Load mappers in themes? - store.set('mapper', await loadMappers(mappers)) - for (const themeFileConfig of themeConfig.files) { - let styleDictionaryConfig: any = {} - if (themeFileConfig.format === 'css/whitepaper') { + for (const entryKey in themeConfig.entry) { + const { mappers, sources, whitepaper } = await loadThemes(themeConfig.entry[entryKey]) + // TODO: Load mappers in themes? + store.set('mapper', await loadMappers(mappers)) + for (const _themeFileConfig of themeConfig.output.files) { + let styleDictionaryConfig: any = {} store.set('whitepaper', whitepaper) - styleDictionaryConfig = createWhitepaperConfig({ + styleDictionaryConfig = createStyleDictionaryConfig({ // TODO: Add sort by platform for all sources. source: sources, - theme: themeConfig.name, - outDir: themeConfig.outDir, + theme: entryKey, + outDir: themeConfig.output.path, }) + const StyleDictionary = StyleDictionaryApi.extend(styleDictionaryConfig) + StyleDictionary.properties = dedupeProps(StyleDictionary.properties) + StyleDictionary.buildPlatform('css') } - const StyleDictionary = StyleDictionaryApi.extend(styleDictionaryConfig) - StyleDictionary.properties = dedupeProps(StyleDictionary.properties) - StyleDictionary.buildPlatform('css') } } }