amzn / style-dictionary

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

How do you overwrite `createPropertyFormatter` indentation formatting? #922

Open redonkulus opened 1 year ago

redonkulus commented 1 year ago

@dbanksdesign

If using the css format (or any built-in format option), there is no way to overwrite the formatting passed into createPropertyFormatter. Since the switch block happens after the variables are created from the values passed in.

Is the solution to just not use the built-in formatter and create my own?

NOTE: If I try to change the format then TypeScript complains because its not a valid format option: Screen Shot 2023-01-26 at 8 51 57 AM

jorenbroekema commented 5 months ago

https://github.com/amzn/style-dictionary/pull/1165 once this is merged and released in v4.0.0-prerelease.27, you will be able to do it like so:

{
  destination: 'variables.css',
  format: 'css/variables',
  options: {
    formatting: { 
      indentation: '    ',
    },
  },
}

indentation just being one example but the other props work as well such as prefix etc.