Created
April 2, 2020 19:01
-
-
Save dbanksdesign/da80cb401c59bd58b29147ee654a8d98 to your computer and use it in GitHub Desktop.
Style Dictionary replacing transform in transformGroup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const StyleDictionary = require('style-dictionary'); | |
// Way 1: | |
// Will run both name transforms, but yours will run last | |
// StyleDictionary.registerTransformGroup({ | |
// name: 'less', | |
// transforms: StyleDictionary.transformGroup.less.concat('name/ti/camel') | |
// }); | |
// Way 2: | |
// This will find and replace the first name transform | |
// found in the transform group | |
const nameIndex = StyleDictionary.transformGroup.less | |
.findIndex(transform => { | |
return transform.startsWith('name') | |
}); | |
StyleDictionary.registerTransformGroup({ | |
name: 'less', | |
transforms: [ | |
...StyleDictionary.transformGroup.less.slice(0, nameIndex), | |
'name/ti/camel', | |
...StyleDictionary.transformGroup.less.slice( nameIndex + 1) | |
] | |
}); | |
// You can also directly modify the transform group | |
// if you export a config object. All transforms, transformGroups, and formats are properties that can be | |
// overriden | |
module.exports = { | |
transformGroup: { | |
less: StyleDictionary.transformGroup.less.concat('name/ti/camel') | |
}, | |
source: [], | |
platforms: { | |
//... | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also, why not?