Skip to content

nexa-vite-plugin API Reference

The @nexa/vite-plugin (distributed as nexa-vite-plugin) is the official Vite integration for building Nexa Single File Components (.nexa).

nexaPlugin

Configures the Vite pipeline to parse, compile, compile styles (with CSS scoping), and inject Hot Module Replacement (HMR) capabilities into Nexa applications.

Signature

typescript
import { Plugin } from 'vite'

export interface NexaPluginOptions {
  include?: string | RegExp | (string | RegExp)[]
  exclude?: string | RegExp | (string | RegExp)[]
  ssr?: boolean
}

export function nexaPlugin(options?: NexaPluginOptions): Plugin

Options

  • include: Minimatch pattern or RegExp matching files to be compiled as Nexa SFCs (defaults to **/*.nexa).
  • exclude: Minimatch pattern or RegExp matching files to be ignored by the compiler.
  • ssr: Boolean toggle to compile components with server-side hydration capabilities (defaults to false unless configured by Vite's SSR target).

Vite Config Example

typescript
import { defineConfig } from 'vite'
import { nexaPlugin } from 'nexa-vite-plugin'

export default defineConfig({
  plugins: [
    nexaPlugin()
  ]
})

Released under the MIT License.