-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
65 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,99 @@ | ||
// TODO: build all currently built files using this setup | ||
|
||
const StyleDictionary = require('style-dictionary') | ||
|
||
const modes = ['compact'] | ||
|
||
console.log(`Building default mode...`) | ||
StyleDictionary.extend({ | ||
source: [ | ||
// exclude non-default modes from source | ||
`./src/**/!(*.${modes.join(`|*.`)}).tokens.json`, | ||
], | ||
function generateSharedConfig(mode) { | ||
const prefix = mode ? `${mode}.` : '' | ||
|
||
platforms: { | ||
return { | ||
css: { | ||
transforms: ['attribute/cti', 'name/cti/kebab', 'color/hsl-4'], | ||
transformGroup: 'css', | ||
buildPath: 'dist/', | ||
files: [ | ||
{ | ||
destination: `root.css`, | ||
format: `css/variables`, | ||
destination: `${prefix}root.css`, | ||
format: 'css/variables', | ||
options: { | ||
outputReferences: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
|
||
cssTheme: { | ||
transforms: ['attribute/cti', 'name/cti/kebab', 'color/hsl-4'], | ||
buildPath: 'dist/', | ||
files: [ | ||
{ | ||
destination: `${prefix}index.css`, | ||
format: 'css/variables', | ||
options: { | ||
selector: '.amsterdam-theme', | ||
outputReferences: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
js: { | ||
transforms: ['attribute/cti', 'name/cti/kebab', 'color/hsl-4'], | ||
buildPath: 'dist/', | ||
files: [ | ||
{ | ||
format: 'javascript/module', | ||
destination: `${prefix}tokens.js`, | ||
}, | ||
], | ||
}, | ||
json: { | ||
transforms: ['attribute/cti', 'name/cti/kebab', 'color/hsl-4'], | ||
buildPath: 'dist/', | ||
files: [ | ||
{ | ||
destination: 'index.tokens.json', | ||
destination: `${prefix}index.tokens.json`, | ||
format: 'json/nested', | ||
}, | ||
], | ||
}, | ||
}, | ||
}).buildAllPlatforms() | ||
|
||
console.log(`\n\n Building compact mode...`) | ||
StyleDictionary.extend({ | ||
source: [`./src/**/*.compact.tokens.json`], | ||
platforms: { | ||
css: { | ||
transformGroup: `css`, | ||
scss: { | ||
transforms: ['attribute/cti', 'name/cti/kebab', 'color/hsl-4'], | ||
buildPath: 'dist/', | ||
files: [ | ||
{ | ||
destination: `compact.css`, | ||
format: `css/variables`, | ||
destination: `${prefix}variables.scss`, | ||
format: 'scss/variables', | ||
options: { | ||
outputReferences: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
typescript: { | ||
transforms: ['attribute/cti', 'name/cti/kebab', 'color/hsl-4'], | ||
transformGroup: 'js', | ||
buildPath: 'dist/', | ||
files: [ | ||
{ | ||
format: 'typescript/module-declarations', | ||
destination: `${prefix}tokens.d.ts`, | ||
}, | ||
], | ||
}, | ||
} | ||
} | ||
|
||
console.log('Building default mode...') | ||
StyleDictionary.extend({ | ||
source: [ | ||
// exclude non-default modes from source | ||
`./src/**/!(*.${modes.join(`|*.`)}).tokens.json`, | ||
], | ||
platforms: generateSharedConfig(), | ||
}).buildAllPlatforms() | ||
|
||
modes.forEach((mode) => { | ||
console.log(`\n\nBuilding ${mode} mode...`) | ||
StyleDictionary.extend({ | ||
source: [`./src/**/*.${mode}.tokens.json`], | ||
platforms: generateSharedConfig(mode), | ||
}).buildAllPlatforms() | ||
}) |