Skip to content

pantoken / bundlers/vite/src / pantoken

函数: pantoken()

pantoken(options?): Plugin

实验性

pantoken 的 Vite 插件。

参数

options?

PantokenViteOptions = {}

PantokenViteOptions.

返回值

Plugin

一个 Vite 插件

示例

在 vite.config.ts 中注册该插件

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

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

将样式表自动注入到 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 })],
});

在应用代码中使用虚拟模块

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