style-dictionary icon indicating copy to clipboard operation
style-dictionary copied to clipboard

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

Open yangchch6 opened this issue 2 years ago • 2 comments

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

yangchch6 avatar Feb 20 '23 09:02 yangchch6

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.

frshwtr avatar Apr 25 '23 15:04 frshwtr

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

torytang025 avatar Oct 15 '23 08:10 torytang025

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.

jorenbroekema avatar Apr 19 '24 14:04 jorenbroekema