Repository: style-dictionary/style-dictionary (JavaScript)

Issue:
options param is not populated when running preprocessor at platform level
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. 

```js
// 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`.



Fix (patch):
diff --git a/.changeset/gentle-lamps-add.md b/.changeset/gentle-lamps-add.md
new file mode 100644
index 000000000..f4d55b749
--- /dev/null
+++ b/.changeset/gentle-lamps-add.md
@@ -0,0 +1,5 @@
+---
+'style-dictionary': patch
+---
+
+Pass PlatformConfig as options param to platform-applied preprocessors.
diff --git a/docs/src/content/docs/reference/Hooks/preprocessors.md b/docs/src/content/docs/reference/Hooks/preprocessors.md
index 766b4a1d8..2cc666e7e 100644
--- a/docs/src/content/docs/reference/Hooks/preprocessors.md
+++ b/docs/src/content/docs/reference/Hooks/preprocessors.md
@@ -6,6 +6,10 @@ Starting in version 4.0, you can define custom preprocessors to process the dict
 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.
 
 Preprocessors can be applied globally or per platform.
+Applying them per platform means the tokens already have some more metadata on them such as "filePath" and "path",
+and the options object resembles the `PlatformConfig` rather than the SD global config options.
+It also allows you to preprocess on a per platform basis, while global means you won't have to repeat the same preprocessing because it will happen once on a global level, so essentially applies to all platforms.
+See [lifecycle diagram](/info/architecture) for a visual diagram of the order of the lifecycle hooks.
 
 :::caution
 It should be clear that using this feature should be a last resort. Using custom parsers to parse per file or using transforms to do transformations on a per token basis,
@@ -21,7 +25,7 @@ That said, preprocessing the full dictionary gives ultimate flexibility when nee
 A preprocessor is an object with two props:
 
 - `name`: the name of the preprocessor
-- `preprocessor` a callback function that receives the dictionary and SD options as parameters, and returns the processed dictionary
+- `preprocessor` a callback function that receives the dictionary and SD options or platform config as parameters, and returns the processed dictionary
 
 ```javascript title="my-preprocessor.js"
 const myPreprocessor = {
@@ -132,7 +136,7 @@ StyleDictionary.registerPreprocessor({
 
 ## Default preprocessors
 
-There are two default preprocessors that are always applied and run before other custom preprocessors do:
+There are two default preprocessors that are always applied and run after other custom preprocessors do:
 
 - [`typeDtcgDelegate`](/reference/utils/dtcg#typedtcgdelegate), for DTCG tokens, make sure the `$type` is either already present or gets inherited from the closest ancestor that has it defined, so that the `$type` is always available on the token level, for ease of use
 - [`expandObjectTokens`](/reference/config#expand), a private preprocessor that will expand object-value (composite) tokens when user config has this enabled.
diff --git a/lib/StyleDictionary.js b/lib/StyleDictionary.js
index 5ce4f3911..884ed7649 100644
--- a/lib/StyleDictionary.js
+++ b/lib/StyleDictionary.js
@@ -443,6 +443,7 @@ export default class StyleDictionary extends Register {
       platformProcessedTokens,
       platformConfig.preprocessors,
       this.hooks.preprocessors,
+      platformConfig,
     );
     if (this.shouldRunExpansion(platformConfig.expand)) {
       platformProcessedTokens = expandTokens(platformProcessedTokens, this.options, platformConfig);
diff --git a/lib/utils/preprocess.js b/lib/utils/preprocess.js
index 0bb83509a..6e68428a0 100644
--- a/lib/utils/preprocess.js
+++ b/lib/utils/preprocess.js
@@ -14,6 +14,7 @@
 /**
  * @typedef {import('../../types/DesignToken.ts').PreprocessedTokens} PreprocessedTokens
  * @typedef {import('../../types/Config.ts').Config} Config
+ * @typedef {import('../../types/Config.ts').PlatformConfig} PlatformConfig
  * @typedef {import('../../types/Preprocessor.ts').Preprocessor} Preprocessor
  */
 
@@ -24,7 +25,7 @@
  * @param {PreprocessedTokens} tokens
  * @param {string[]} [appliedPreprocessors]
  * @param {Record<string, Preprocessor['preprocessor']>} [preprocessorObj]
- * @param {Config} [options]
+ * @param {Config|PlatformConfig} [options]
  * @returns {Promise<PreprocessedTokens>}
  */
 export async function preprocess(
diff --git a/types/Preprocessor.ts b/types/Preprocessor.ts
index 240a49334..d6e12c024 100644
--- a/types/Preprocessor.ts
+++ b/types/Preprocessor.ts
@@ -12,12 +12,12 @@
  */
 
 import type { PreprocessedTokens } from './DesignToken.ts';
-import type { Config } from './Config.ts';
+import type { Config, PlatformConfig } from './Config.ts';
 
 export type Preprocessor = {
   name: string;
   preprocessor: (
     dictionary: PreprocessedTokens,
-    options: Config,
+    options: Config | PlatformConfig,
   ) => PreprocessedTokens | Promise<PreprocessedTokens>;
 };