Closed uptonking closed 3 years ago
You should be able to put both bootstrap
and bootswatch-flaty
in the include
paths array. Files found in include
should not have any issues with conflicts. Those files will be deep-merged and won't throw any warnings or errors if there are conflicts (the later files defined in the include array will take precedence). Files found in source
will take precedence over those in include. You will only get a collision warning if multiple files defined in source
define the same tokens. Here is a tiny sample of that working:
// build.js
const StyleDictionary = require('style-dictionary');
StyleDictionary.extend({
include: [
`include1.json`,
`include2.json`
],
source: [
`source.json`
],
platforms: {
css: {
transformGroup: `css`,
files: [{
destination: `variables.css`,
format: `css/variables`
}]
}
}
}).buildAllPlatforms();
// include1.json
{
"foo": { "value": "bar" }
}
// include2.json
{
"foo": { "value": "foo" }
}
// source.json
{
"foo": { "value": "boo" }
}
That should build fine and foo
's value should be "boo"
.
Going off your example, you could have 3 directories: bootstrap
, bootswatch-flaty
, and bootswatch-flaty-dark
and then run Style Dictionary 3 times with the include and source configuration like this:
// build.js
const StyleDictionary = require('style-dictionary');
// bootstrap
StyleDictionary.extend({
source: [
`bootstrap/**/*.json`
],
platforms: {
//...
}
}).buildAllPlatforms();
// bootswatch-flaty
StyleDictionary.extend({
include: [
`bootstrap/**/*.json`
],
source: [
`bootswatch-flaty/**/*.json`
],
platforms: {
//...
}
}).buildAllPlatforms();
// bootswatch-flaty-dark
StyleDictionary.extend({
include: [
`bootstrap/**/*.json`,
`bootswatch-flaty/**/*.json`
],
source: [
`bootswatch-flaty-dark/**/*.json`
],
platforms: {
//...
}
}).buildAllPlatforms();
Does that make sense?
@dbanksdesign
my use case: how to implement three themes like
bootstrap, bootswatch-flaty, bootswatch-flaty-dark
my goal is like this:
isSource
i have 2 ideas
option 1: refactor style-dictionary core to support more config levels than
include, source
include
path, it will have conflictsoption 2: modify according to advanced example
multi-brand-multi-platform
any good idea?