Unplugin API reference
Source information
- Package:
@pikacss/unplugin-pikacss - Generated from the exported surface and JSDoc in
packages/unplugin/src/index.ts. - Source files:
packages/unplugin/src/index.ts,packages/unplugin/src/types.ts
Package summary
Universal bundler plugins for Vite, Webpack, Rspack, esbuild, Rollup, Rolldown, and Farm Re-exports the public surface of @pikacss/integration.
Use Unplugin integration when you need conceptual usage guidance instead of exact symbol lookup.
Constants
default
Pre-built universal bundler plugin for PikaCSS.
Remarks:
Created by passing unpluginFactory to createUnplugin. Import the bundler-specific sub-path (e.g., @pikacss/unplugin-pikacss/vite) for a ready-to-use plugin instance.
// vite.config.ts
import pika from '@pikacss/unplugin-pikacss/vite'
export default defineConfig({
plugins: [pika()],
})unpluginFactory
Factory function that produces the bundler-agnostic PikaCSS plugin hooks.
Remarks:
This is the core entry-point called by createUnplugin. It resolves user options, creates an integration context via createCtx, and wires bundler-specific lifecycle hooks (config resolution, dev-server HMR, build transforms, and config file watching).
import { unpluginFactory } from '@pikacss/unplugin-pikacss'
import { createUnplugin } from 'unplugin'
const plugin = createUnplugin(unpluginFactory)unpluginPika
Pre-built universal bundler plugin for PikaCSS.
Remarks:
Created by passing unpluginFactory to createUnplugin. Import the bundler-specific sub-path (e.g., @pikacss/unplugin-pikacss/vite) for a ready-to-use plugin instance.
// vite.config.ts
import pika from '@pikacss/unplugin-pikacss/vite'
export default defineConfig({
plugins: [pika()],
})Types
PluginOptions
User-facing configuration options for the PikaCSS bundler plugin.
| Property | Type | Description | Default |
|---|---|---|---|
scan? | { /** * File glob patterns to scan. Supports a single string or array of strings. * @default ['**\/*.{js,ts,jsx,tsx,vue}'] */ include?: string | string[] /** * File glob patterns to exclude. Supports a single string or array of strings. * @default ['node_modules/**', 'dist/**'] */ exclude?: string | string[] } | Glob patterns controlling which source files are scanned for pika() calls. | { include: ['**\/*.{js,ts,jsx,tsx,vue}'], exclude: ['node_modules/**', 'dist/**'] } |
config? | EngineConfig | string | Engine configuration object or a path to a pika.config.* file. When omitted, the plugin auto-discovers a config file in the project root. | ``undefined (auto-discover) |
autoCreateConfig? | boolean | When true, automatically scaffolds a default pika.config.js file if no existing config is found. | true |
fnName? | string | Base function name to recognize in source code. All variants (.str, .arr, preview) are derived from this name. | 'pika' |
transformedFormat? | 'string' | 'array' | Default output format for normal pika() calls. 'string' produces a space-joined class string; 'array' produces a string array of class names. | 'string' |
tsCodegen? | boolean | string | Controls TypeScript declaration codegen. true writes to 'pika.gen.ts', a string sets a custom output path, and false disables codegen entirely. | true |
cssCodegen? | true | string | Controls CSS output file generation. true writes to 'pika.gen.css'; a string sets a custom output path. | true |
currentPackageName? | string | npm package name of the plugin consumer, embedded in generated file headers and import paths. Override when wrapping the unplugin in a framework-specific package (e.g., @pikacss/nuxt). | '@pikacss/unplugin-pikacss' |
Remarks:
Passed to the unplugin factory when creating a Vite, webpack, Rollup, or esbuild plugin. All properties are optional — sensible defaults are applied for zero-config setups.
import pika from '@pikacss/unplugin-pikacss/vite'
export default defineConfig({
plugins: [
pika({
config: './pika.config.ts',
fnName: 'css',
transformedFormat: 'array',
}),
],
})ResolvedPluginOptions
Normalized plugin configuration with all defaults applied and boolean shorthands expanded.
| Property | Type | Description | Default |
|---|---|---|---|
currentPackageName | string | npm package name of the integration consumer, used in generated file headers and import paths. | — |
configOrPath | EngineConfig | string | Nullish | Engine configuration object, a path to a config file, or null/undefined for auto-discovery. | — |
tsCodegen | false | string | Resolved TypeScript codegen output path, or false when codegen is disabled. | — |
cssCodegen | string | Resolved CSS output file path (always a string after defaults are applied). | — |
scan | IntegrationContextOptions['scan'] | Normalized include/exclude glob arrays controlling source file scanning. | — |
fnName | string | Base function name to recognize in source transforms (e.g., 'pika'). | — |
transformedFormat | 'string' | 'array' | Default output format for normal pika() calls: 'string' or 'array'. | — |
autoCreateConfig | boolean | Whether to scaffold a default config file when none is found. | — |
Remarks:
Produced internally by the unplugin factory from PluginOptions. Consumers should not construct this type directly — it exists so that internal helpers receive fully resolved, non-optional values.