Preprocessors
Starting in version 4.0, you can define custom preprocessors to process the dictionary object as a whole, after it all token files have been parsed and combined into one. This is useful if you want to do more complex transformations on the dictionary as a whole, when all other ways are not powerful enough.
That said, preprocessing the full dictionary gives ultimate flexibility when needed.
Preprocessor structure
A preprocessor is an object with two props:
name
: the name of the preprocessorpreprocessor
a callback function that receives the dictionary as a parameter, and returns the processed dictionary
Asynchronous callback functions are also supported, giving even more flexibility.
Using preprocessors
First you will need to tell Style Dictionary about your parser. You can do this in two ways:
- Using the
.registerPreprocessor
method - Inline in the configuration
.registerPreprocessor
Inline
Preprocessor examples
Stripping description property recursively in the entire dictionary object: