Closed VijaytaWJ closed 1 month ago
https://styledictionary.com/version-4/migration/ you'll need to adjust your code for v4, StyleDictionary.extend
is no longer the method for initialising a dictionary, you need to use:
import StyleDictionary from 'style-dictionary';
// initialise Style Dictionary
const sd = new StyleDictionary({
source: ['tokens/**/*.json'],
platforms: {
dart: {
transformGroup: 'dart',
buildPath: 'build/dart/',
files: [
{
destination: 'tokens.dart',
format: 'dart/class',
options: {
className: 'RIBUIT',
},
},
],
},
},
});
await sd.buildAllPlatforms();
thanks Jorenbrokekema, i fixed that by using new StyleDictionary constructor. However i now get error while registering transformer, the error is get is Error: transform must be a function
StyleDictionary.registerTransform({ name: 'name', type: 'name', transformer: (token, _, options) => { return token.name; } });
transformer
was changed to transform
, I would advise going through the migration docs entirely and maybe run the codemods that are available since recently to automatically try to migrate your code from v3 to v4
Thanks for suggestions, changing it to transform worked
Hello All, I am trying to use StyleDictionary as a module, the following is the code.
however i get error as "TypeError: StyleDictionary.extend is not a function " , i checked the path, it is referring to the correct StyleDictonary.js and it does have a extend method, have read many tutorials to double check the configuration but not sure what the issue is
Style dictionary version 4.1.2 and node js version 20.17.0