-
Notifications
You must be signed in to change notification settings - Fork 572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom transform not working with hooks in Style Dictionary 4 #1426
Comments
Try export default {
source: [flattenedTokensPath],
hooks: {
transforms: {
CssCustomPrefix: {
type: 'value',
transform: (token) => {
console.log("test"); // This is never logged
return token.value;
},
},
},
},
platforms: {
css: {
transforms: ["CssCustomPrefix"],
buildPath: "src/css/",
files: [
{
destination: "color.css",
format: formats.cssVariables,
filter: {
type: "color",
},
},
],
}
}
};
|
@jorenbroekema I have a question. Why is there a distinction between inlining transform in hooks and registerTransform? |
My answer would be that this distinction was always there since the start of the library, just the shape of it has been adjusted for clarity (e.g. putting it inside a hooks wrapper object). The reason for this is mostly because in the old library, Style Dictionary was "just an object" and completely mutable, so while you were advised to use the "registerTransform" etc. methods, you could always just mutate the SD object yourself to register it manually and essentially do whatever you like. |
@jorenbroekema |
I'm trying to implement a custom transform using hooks in Style Dictionary 4, but the transform is not being executed. Here's my configuration:
I'm running the build with:
pnpm exec style-dictionary build --config src/style-dictionary/transform-token.js
I also tried using transform groups like this:
But neither approach seems to work - the transform is never executed (no console.log output).
Expected behavior:
The custom transform should be executed
console.log in the transform should be visible in the output
Actual behavior:
The transform appears to be ignored
No console.log output is visible
The build completes successfully but without applying the custom transform
Environment:
Style Dictionary version: 4.3.0
Node.js version: 20.16.0
Package manager: pnpm
Any help or guidance would be appreciated!
The text was updated successfully, but these errors were encountered: