Skip to content

Commit

Permalink
Build all agreed upon files
Browse files Browse the repository at this point in the history
  • Loading branch information
alimpens committed Feb 9, 2024
1 parent 01ff892 commit 6d55d9a
Showing 1 changed file with 65 additions and 25 deletions.
90 changes: 65 additions & 25 deletions proprietary/tokens/build.js
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()
})

0 comments on commit 6d55d9a

Please sign in to comment.