Skip to content

Commit

Permalink
feat: registers Tokens Studio transforms; build-tokens:watch NPM script
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstankiewicz committed Sep 7, 2024
1 parent 029325a commit 2667256
Show file tree
Hide file tree
Showing 5 changed files with 243 additions and 144 deletions.
7 changes: 6 additions & 1 deletion lib/build-tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const path = require('path');
const minimist = require('minimist');
const {
initializeStyleDictionary,
getTokensStudioTransforms,
colorTransform,
} = require('../tokens/style-dictionary');
const { createIndexCssFile } = require('../tokens/utils');
Expand Down Expand Up @@ -56,9 +57,14 @@ async function buildTokensCommand(commandArgs) {
source: tokensSource
? [`${tokensSource}/core/**/*.json`, `${tokensSource}/core/**/*.toml`]
: [],
preprocessors: ['tokens-studio'],
expand: {
typesMap: (await getTokensStudioTransforms()).expandTypesMap,
},
platforms: {
css: {
prefix: 'pgn',
transformGroup: 'paragon-css',
// NOTE: buildPath must end with a slash
buildPath: buildDir.slice(-1) === '/' ? buildDir : `${buildDir}/`,
options: {
Expand All @@ -82,7 +88,6 @@ async function buildTokensCommand(commandArgs) {
},
},
],
transforms: StyleDictionary.hooks.transformGroups.css.filter(item => item !== 'size/rem').concat('color/sass-color-functions', 'str-replace'),
},
},
log: {
Expand Down
64 changes: 64 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@
"playroom:build": "npm run playroom:build --workspace=www",
"prepare": "husky || true",
"build-tokens": "./bin/paragon-scripts.js build-tokens --build-dir ./styles/css",
"build-tokens:watch": "npx nodemon --ignore styles/css -x \"npm run build-tokens\"",
"replace-variables-usage-with-css": "./bin/paragon-scripts.js replace-variables -p src -t usage",
"replace-variables-definition-with-css": "./bin/paragon-scripts.js replace-variables -p src -t definition",
"cli:help": "./bin/paragon-scripts.js help"
},
"dependencies": {
"@popperjs/core": "^2.11.4",
"@tokens-studio/sd-transforms": "^1.2.4",
"axios": "^0.27.2",
"bootstrap": "^4.6.2",
"chalk": "^4.1.2",
Expand Down
Loading

0 comments on commit 2667256

Please sign in to comment.