JavaScript (and TypeScript)
Terrazzo’s JS plugin generates JavaScript, TypeScript, and JSON output from your tokens.
Setup
npm i -D @terrazzo/plugin-js
pnpm i -D @terrazzo/plugin-js
import pluginJS from "@terrazzo/plugin-js";
/** @type {import("@terrazzo/cli").Config} */
export default {
plugins: [
pluginJS({
output: {
js: "index.js",
ts: "index.d.ts",
json: false, // set to a filename to generate JSON
},
}),
],
};
Usage
import token from "./tokens/index.js";
token("color.blue.500");
Config
Configure options in terrazzo.config.js:
import pluginJS from "@terrazzo/plugin-js";
/** @type {import("@terrazzo/cli").Config} */
export default {
plugins: [
pluginJS({
/* options */
}),
],
};
Options
Name | Type | Description |
---|---|---|
js | string | boolean | Set to a filename, or false to disable (default: index.js ). |
ts | string | boolean | Set to a filename, or false to disable (default: index.d.ts ) Note: this can’t be enabled if js is disabled). |
json | string | boolean | Set to a filename, or false to disable (default: false ). |