style-dictionary
style-dictionary copied to clipboard
Format scss/map-deep fails if value is string or null
If the token file contains values that are null or strings then (under some circumstances) the parsing fails (error message: TypeError: Cannot read property 'hasOwnProperty' of null
).
spike.js
const StyleDictionary = require('style-dictionary')
const StyleDictionaryExtended = StyleDictionary.extend({
"source": ["./spike.tokens.json"],
"platforms": {
"scss": {
"transformGroup": "scss",
"files": [{
"destination": "spike.variables.scss",
"format": "scss/map-deep"
}]
}
}
}
)
StyleDictionaryExtended.buildAllPlatforms()
spike.tokens.js
{
"color": {
"primary": {
"brand orange": {
"type": "color",
"value": "orange"
},
"brand blue": {
"type": "color",
"value": "blue"
},
"description": null
}
}
}
I do have a solution for this and will create a pull request for it.