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

The custom format helpers `createPropertyFormatter` does not support passing formatting options #941

Closed yangchch6 closed 5 months ago

yangchch6 commented 1 year ago

In the createPropertyFormatter function, I can't pass in custom formatting attributes, because it will be overridden by hard-coded prefix='--'

image

This code should be changed like this, could you support the fix of this problem? image

frshwtr commented 1 year ago

Hello.

I have found the way to get around this is to not set the format property. You will then need to define all the other formatting styles you need though. This does have some caveats however which makes me think this isn't how it should work.

Bumping this as I would like to be able to use a prefix with format also being set. In my project, if i remove format to get the desired prefix, then I lose the behaviour of outputReferences. I require both for my use case.

torytang025 commented 11 months ago

I had the same problem. It seems like a bug 😢 For me, I copied this file and rewrote it like your proposal

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.