Advanced

Compiler

Build-time Babel/Vite plugin that extracts token props and emits atomic CSS.

How It Works

The compiler traverses your JSX AST at build time, detects token props, and replaces them with atomic CSS class names — zero runtime overhead.

JSX Source
AST Traverse
Detect Tokens
Emit CSS Classes
Replace Props

Before & After

Before
<Box
  bg={colors.celurenBlue[500]}
  p={spacing[4]}
/>
After
<Box
  className="sz-bg-celurenBlue-500
             sz-p-spacing-4"
/>

Generated CSS:

:root {
  --celurenBlue-500: #024CCE;
  --spacing-4: 4px;
}

.sz-bg-celurenBlue-500 {
  background-color: var(--celurenBlue-500);
}
.sz-p-spacing-4 {
  padding: var(--spacing-4);
}

Vite Plugin

// vite.config.ts
import { stareezyVitePlugin } from '@stareezy-ui/compiler'

export default {
  plugins: [
    stareezyVitePlugin({
      cssVariablePrefix: 'sz',
      outputDir: 'dist/styles',
    }),
  ],
}

Babel Plugin

// babel.config.js
module.exports = {
  plugins: [
    ['@stareezy-ui/compiler/babel', {
      cssVariablePrefix: 'sz',
    }],
  ],
}

Prop Mappings

JSX PropCSS Property
bgbackground-color
colorcolor
ppadding
pxpadding-left, padding-right
pypadding-top, padding-bottom
mmargin
roundedborder-radius
fontSizefont-size
fontWeightfont-weight

Non-Token Props

Props with plain string or number values are left completely unchanged:

// Token prop → replaced with class name ✓
<Box bg={colors.celurenBlue[500]} />

// Plain value → passed through unchanged ✓
<Box bg="#024CCE" />
The compiler deduplicates CSS rules — even if the same token is used in 100 components, only one CSS rule is generated per build.

CSS Deduplication

The compiler generates each CSS rule at most once per build, regardless of how many components reference the same token. This keeps your CSS bundle minimal even at scale.