Skip to main content Skip to docs navigation

preprocessor.js

Token preprocessing for Style Dictionary

preprocessor.js

This script defines a custom preprocessor for Style Dictionary. The preprocessor aligns token types, adds metadata, and resolves font styles before the main transformation process.

Key Responsibilities

  • Aligns token types to Style Dictionary conventions
  • Adds metadata (e.g., original type) to tokens
  • Resolves and normalizes font style and shadow properties
  • Handles reference resolution for token values

Example Usage

import cxPrep from './preprocessor.js'
StyleDictionary.registerPreprocessor({
  name: 'cx/global',
  preprocessor: (dictionary) => cxPrep(dictionary)
})

See Also