SayKit
Integrations

Vite (unplugin)

Use SayKit with Vite, Rollup, Rolldown, Webpack, Rspack, esbuild, Farm, or Bun

unplugin-saykit is the SayKit plugin for every bundler unplugin supports. Only the import path changes between them.

Install

pnpm add -D unplugin-saykit @saykit/config @saykit/format-po @saykit/transform-js @saykit/transform-jsx

Use

vite.config.ts
import saykit from 'unplugin-saykit/vite';
import { defineConfig } from 'vite';

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

The plugin takes no options; it reads saykit.config.ts.

What it does

It does two things:

  • Compiles catalogues. When the build starts, it compiles each catalogue into an ordinary {locale}.js module, as saykit compile does. In a dev server or watch mode it recompiles whenever a catalogue changes, so editing en.po rewrites every locale that falls back to it. The bundler loads, splits and hot-reloads those modules like any other. A module that would not change is not rewritten, so the plugin and extract --watch never trigger reloads for each other.
  • Rewrites macros in every file a bucket includes, so say`Hello, ${name}!` becomes say.call({ id: '…', _name: name }).

Keep saykit extract --watch running in development so the source catalogue follows your code.

Notes

  • Ordering. The plugin runs with enforce: 'pre', so it sees macros before other transforms. A plugin that lowers tagged templates must run after it.
  • Vite works beside @vitejs/plugin-react and TanStack Start. Vitest picks the plugin up from vite.config.ts, which the macros need.
  • Next.js should use babel-plugin-saykit instead.

Next

On this page