Skip to content

pantoken / bundlers/vite/src / pantoken

Function: pantoken()

pantoken(options?): Plugin

Experimental

The pantoken Vite plugin.

Parameters

options?

PantokenViteOptions = {}

PantokenViteOptions.

Returns

Plugin

A Vite Plugin.

Examples

Register the plugin in vite.config.ts

ts
import { defineConfig } from "vite";
import { pantoken } from "@pantoken/vite";

export default defineConfig({
  plugins: [pantoken()],
});

Auto-inject the stylesheet into the HTML <head>

ts
import { defineConfig } from "vite";
import { pantoken } from "@pantoken/vite";

export default defineConfig({
  // No need to import `virtual:pantoken/css` yourself — it's injected.
  plugins: [pantoken({ injectCss: true })],
});

Consume the virtual modules in app code

ts
import css from "virtual:pantoken/css"; // the stylesheet string
import { tokens } from "virtual:pantoken/tokens"; // the resolved token IR