JavaScript / TypeScript
warning
There will be some upcoming breaking changes (TBD) to the JS plugin in Terrazzo 2.0 stable to support the DTCG Resolver module.
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 js from "@terrazzo/plugin-js";
export default defineConfig({
plugins: [
js({
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 js from "@terrazzo/plugin-js";
export default defineConfig({
plugins: [
js({
/* 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). |