Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update docs to latest SD #281

Merged
merged 1 commit into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

![NPM version badge](https://img.shields.io/npm/v/@tokens-studio/sd-transforms) ![License badge](https://img.shields.io/github/license/tokens-studio/sd-transforms)

> Note: this README contains examples that assume latest version of this package & v4 style-dictionary latest prerelease.

## Table of contents

- [Installation](#installation)
Expand Down Expand Up @@ -86,8 +88,10 @@ import StyleDictionary from 'style-dictionary';
// that is installed as a dependency of this package.
registerTransforms(StyleDictionary);

const sd = StyleDictionary.extend({
source: ['**/*.json'], // <-- make sure to have this match your token files!!!
const sd = new StyleDictionary({
// make sure to have source match your token files!
// be careful about accidentally matching your package.json or similar files that are not tokens
source: ['tokens/**/*.json'],
preprocessors: ['tokens-studio'], // <-- since 0.16.0 this must be explicit
platforms: {
css: {
Expand All @@ -104,8 +108,8 @@ const sd = StyleDictionary.extend({
},
});

sd.cleanAllPlatforms();
sd.buildAllPlatforms();
await sd.cleanAllPlatforms();
await sd.buildAllPlatforms();
```

> You can also import as ES Modules if needed.
Expand All @@ -125,7 +129,7 @@ you must add the `'tokens-studio'` preprocessor explicitly in the configuration:

```json
{
"source": ["**/*.tokens.json"],
"source": ["tokens/**/*.json"],
"preprocessors": ["tokens-studio"],
"platforms": {}
}
Expand All @@ -135,7 +139,7 @@ you must add the `'tokens-studio'` preprocessor explicitly in the configuration:

```json
{
"source": ["**/*.tokens.json"],
"source": ["tokens/**/*.json"],
"preprocessors": ["tokens-studio"],
"platforms": {
"css": {
Expand Down Expand Up @@ -278,11 +282,12 @@ async function run() {
},
}));

configs.forEach(cfg => {
const sd = StyleDictionary.extend(cfg);
sd.cleanAllPlatforms(); // optionally, cleanup files first..
sd.buildAllPlatforms();
});
async function cleanAndBuild(cfg) {
const sd = new StyleDictionary(cfg);
await sd.cleanAllPlatforms(); // optionally, cleanup files first..
await sd.buildAllPlatforms();
}
await Promise.all(configs.map(cleanAndBuild));
}

run();
Expand Down Expand Up @@ -410,11 +415,12 @@ async function run() {
},
}));

configs.forEach(cfg => {
const sd = StyleDictionary.extend(cfg);
sd.cleanAllPlatforms(); // optionally, cleanup files first..
sd.buildAllPlatforms();
});
async function cleanAndBuild(cfg) {
const sd = new StyleDictionary(cfg);
await sd.cleanAllPlatforms(); // optionally, cleanup files first..
await sd.buildAllPlatforms();
}
await Promise.all(configs.map(cleanAndBuild));
}

run();
Expand Down
Loading