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

Using filter to export multiple JSON files

Open francinen opened this issue 4 years ago • 4 comments

I'm trying to export a single JSON file for all my color tokens, using the following config options:

        {
          "destination": "colors.json",
          "format": "json/nested",
          "filter": {
            "attributes": {
              "category": "color"
            }
          }
        },

My tokens/color.json file looks like this (I've also tried nesting it under tokens/color/color.json :

{
  "color": {
    "surface":{
      "background":{
        "primary":{"value": "#FFFFFF"},
        "secondary":{"value": "#F8F8F8"}
      },
      "card":{
        "primary":{"value": "#F8F7F6"},
        "secondary":{"value": "#FFFFFF"},
        "disabled":{"value": "#D7D7D7"}
      }
    },
   // etc.
}

When I run the build command, I see a note that No properties for colors.json. File not created.

What am I missing in my config file?

francinen avatar Dec 01 '21 18:12 francinen

Are you targeting the correct file? You mention that your file name is tokens/color.json (singular) but the error message reports colors.json (plural).

If not, can you copy all your configuration file?

silversonicaxel avatar Dec 02 '21 07:12 silversonicaxel

@francinen How does the whole object in the config.json file look like?

isellsoap avatar Dec 13 '21 09:12 isellsoap

@francinen did you still need help, or did these comments solve your issue?

chazzmoney avatar Feb 15 '22 22:02 chazzmoney

@francinen Have you found solution to this? I am facing the same issue.

SiddharthMaheshwari91 avatar Sep 18 '23 04:09 SiddharthMaheshwari91