JavaScript (and TypeScript)
Terrazzo’s JS plugin generates JavaScript, TypeScript, and JSON output from your tokens.
Setup
npm i -D @terrazzo/plugin-jspnpm i -D @terrazzo/plugin-jsbun i -D @terrazzo/plugin-jsimport { defineConfig } from "@terrazzo/cli";
import pluginJS from "@terrazzo/plugin-js";
export default defineConfig({
plugins: [
pluginJS({
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 { defineConfig } from "@terrazzo/cli";
import pluginJS from "@terrazzo/plugin-js";
export default defineConfig({
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). |