@secundus-studio/stift-vite-plugin
v0.4.32
Published
Vite plugin wiring @secundus-studio/stift-generator into the build: dev raw-JSON, prod compiled packs, devtools file-write bridge.
Downloads
654
Readme
@secundus-studio/stift-vite-plugin
Vite/rolldown integration for Stift: wires @secundus-studio/stift-generator into dev and build so the app always sees the latest strings as compiled packs.
What it is
The build plugin for Stift apps. It re-runs typegen (stift.gen.d.ts), incrementally compiles locales/** into content-addressed packs, and exposes them to the app through two virtual modules — virtual:stift/runtime (createStiftRuntime(), spread into createStift(...)) and virtual:stift/catalog (the pack index). SSR environments instead read locales/ straight off disk via FsJsonSource, so no node-only code leaks into the browser graph.
Install
pnpm add -D @secundus-studio/stift-vite-pluginBuild tooling — install as a devDependency. Vite itself is a peer dependency (any Vite app already has it).
Quick start
// vite.config.ts
import { defineConfig } from 'vite'
import { stiftPlugin } from '@secundus-studio/stift-vite-plugin'
export default defineConfig({
plugins: [
stiftPlugin({
// assetsDir: 'stift',
// outputFile: 'src/stift.gen.d.ts',
}),
],
})// app entry
import { createStift } from '@secundus-studio/stift-core'
import { createStiftRuntime } from 'virtual:stift/runtime'
export const stift = createStift(createStiftRuntime())Options
stiftPlugin(userOptions) — all options optional:
| Option | Default | Meaning |
|---|---|---|
| assetsDir | 'stift' | Relative dir inside outDir where pack assets are emitted |
| outputFile | 'src/stift.gen.d.ts' | Path (relative to root) for the generated .d.ts |
| logLevel | 'info' | Per-plugin log gate: 'info', 'warn', 'error', or 'silent' |
| devServePacks | true | Serve compiled packs through dev-server middleware; set false for SSR-only apps that don't consume packs in dev |
| devtools | file writes off | { allowFileWrites: true } mounts the write bridge the devtools panel edits locale files through |
| watch | — | Extra absolute paths/globs to watch for regeneration in dev |
How it works
In dev, edits to locales/** or the config re-run typegen, recompile only the changed namespaces, invalidate the virtual modules, and trigger a reload — while the dev-server middleware serves the exact same pack bytes prod will emit. In prod builds, the compiled packs (plus catalog.json for update checks) are emitted through the asset pipeline in buildStart.
Docs
- Build: Vite plugin & CLI — https://stift.secundus.studio/docs/latest/react/tooling/build
- Devtools — https://stift.secundus.studio/docs/latest/react/tooling/devtools
- Config file — https://stift.secundus.studio/docs/latest/react/configuration/config-file
