Question is simple:
I've a javascript file
const StyleDictionary = require('style-dictionary').extend('color-config.json');
and a json config file
{
"source": ["tokens/color.json"],
"platforms": {
"css": {
"transforms": ["color/css"],
Since I'm using a particular architecture, I need to prefix the source of all token config jsons with a pre path, so currently the situation is the following in my build process the source tokens/color.json
is not working, instead I need to use for instance something like this /extra/architecture/private/tokens/color.json
.
But I would like not to append this pre path in the json directly, I would like to be able to add it maybe via javascript through one single config parameter.
At the moment I couldn't find a good way to do it, only good approach is to edit directly the config json file.
Any better ideas?
Here is the answer, extend
can be reworked multiple times, and returns the new updated object handler of Style Dictionary.
const StyleDictionary = require('style-dictionary').extend('color-config.json');
StyleDictionary.extend({
source: StyleDictionary?.options?.source
? StyleDictionary.options.source.map(
source => `extra/architecture/private/${source}`
)
: [],
platforms: StyleDictionary.options.platforms,
}).buildAllPlatforms();