amzn / style-dictionary

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

options param is not populated when running preprocessor at platform level #1365

Closed bigglesrocks closed 1 month ago

bigglesrocks commented 1 month ago

I have a custom preprocessor which I want to run only on a single platform, however I want access to the config via the options param that is passed to the preprocess function. If I specify this preprocessor at the root level, the options param is populated with the config as expected, however, specified on a single platform, the options object is empty. I would expect to get either the full config object or platform configuration, preferably both.

// config.js
{
  hooks: { 
   preprocessors: { 
    'my-custom-preprocessor': (tokens, options) => {
     console.log(options);
    }
   },
  // when specified at the root level, the console statement in the preprocessor function
  // will log out this config object as expected 👍
    preprocessors: ['my-custom-preprocessor'],  
    platforms: {
      css: { 
        files: [{ // basic css file }],
        transformGroup: 'css',
        // when specified on a platform, the console statement only logs an empty object: {} 😢
        preprocessors: ['my-custom-preprocessor'], 
      }
    }
  }
}

I've tested this in a barebones StyleDictionary project using v4.1.3. Also want to note that it makes no difference whether the preprocessor is defined inline like in the example or registered with registerPreprocessor.