amzn / style-dictionary

A build system for creating cross-platform styles.
https://styledictionary.com
Apache License 2.0
3.93k stars 557 forks source link

Each platform needs different source files #976

Open wzamites opened 1 year ago

wzamites commented 1 year ago

I have the following folder structure:

tokens
  /core.json
  /light-colors.json
  /dark-colors.json

light-colors.json and dark-colors.json have identically named attributes but have differnet values. This is so that the files can be interchanged depending on if the application is in dark mode or light mode.

For exmaple: light-colors.json: "grey": "#D3D3D3" dark-colors.json: "grey": "#5A5A5A"

However, since the colors are identically named, I am not able to include all 3 of these files in the source or include arrays. The identical naming introduces collisions.

I would prefer to specify these different souces within the files object within the platforms object in the config. For now it looks like the only solution is to define entirely differnet dictionaries for every configuration of tokens I have, and run buildAllPlatforms() many times, effectively bypassing the platforms functionality.

Has anyone else come across this? What are some solutions?

nahiyankhan commented 1 year ago

Would something like the multi-brand multi-platform example work for you? You wouldn't be defining different dictionary. Its the same dictionary, with the same configs but looped with different source files. We do a variation of that. Loop modes, loop platforms. All share same custom transforms, formats etc.