Using the CLI
Basic Usage
Section titled “Basic Usage”dispersa buildThe CLI discovers your configuration automatically and builds all configured outputs.
Config File
Section titled “Config File”The CLI looks for a config file named dispersa.config.ts (or .js, .mts, .mjs, .cts, .cjs) in your project root. Use defineConfig for type safety:
import { defineConfig } from 'dispersa/config'import { css, json } from 'dispersa'import { colorToHex } from 'dispersa/transforms'
export default defineConfig({ resolver: './tokens.resolver.json', buildPath: './dist', outputs: [ css({ name: 'css', file: 'tokens.css', preset: 'bundle', selector: ':root', transforms: [colorToHex()], }), json({ name: 'json', file: 'tokens-{theme}.json', preset: 'standalone', structure: 'flat', }), ],})Custom Config Path
Section titled “Custom Config Path”To use a config file in a different location:
dispersa build --config ./my-config.tsLint Command
Section titled “Lint Command”Run linting independently of the build:
dispersa lintThe lint command requires a lint configuration in your config file:
import { defineConfig } from 'dispersa/config'import { dispersaPlugin } from 'dispersa/lint'
export default defineConfig({ resolver: './tokens.resolver.json', lint: { plugins: { dispersa: dispersaPlugin }, rules: { 'dispersa/require-description': 'warn', }, },})Lint Options
Section titled “Lint Options”| Flag | Description |
|---|---|
--config <path> | Path to config file (same as build) |
--format <format> | Output format: stylish (default), json, compact |
--verbose, -v | Show detailed output |
Output Formats
Section titled “Output Formats”stylish(default) — Human-readable output with color-coded issuesjson— JSON output for CI pipelinescompact— Single-line output with issue counts
How It Works
Section titled “How It Works”The CLI uses jiti for dynamic ESM imports, so you can use TypeScript config files (dispersa.config.ts) without precompiling them.
Project Structure Recommended directory layouts for organizing tokens, resolver, and build configuration.