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

filter out specific files from source array #880

Open eendkonijn opened 1 year ago

eendkonijn commented 1 year ago

Hello, I have a group of json files as the source for design tokens source: ["properties/**/*.json"] . I want to target just one of the files. Below I filter by category, is it also possible to put one specific filepath under files.filter and if so, how?

image

chris-dura commented 1 year ago

There's some examples floating around, but you can look at the token's filePath...

platforms: {
    css: {
      transformGroup: `css`,
      buildPath: webPath,
      files: [{
        destination: `variables-dark.css`,
        format: `css/variables`,
        // only putting in the tokens from files with '.dark' in the filepath
        filter: (token) => token.filePath.indexOf(`.dark`) > -1,
        options: {
          outputReferences: true
        }
      }]
    },