@fluenti/vite-plugin
v0.5.0
Published
Vite plugin for Fluenti — build-time transforms, virtual modules, code splitting
Maintainers
Readme
@fluenti/vite-plugin
The build-time engine behind Fluenti. This is an internal package that provides the core Vite plugin infrastructure. Users should install the framework-specific packages instead.
Usage
This package is not meant to be used directly. Install your framework package instead:
# Vue
pnpm add @fluenti/vue
# React
pnpm add @fluenti/react
# Solid
pnpm add @fluenti/solidThen import the Vite plugin from the framework package's subpath export:
// Vue — vite.config.ts
import vue from '@vitejs/plugin-vue'
import fluentiVue from '@fluenti/vue/vite-plugin'
export default {
plugins: [
vue(),
fluentiVue({
sourceLocale: 'en',
locales: ['en', 'ja', 'zh-CN'],
splitting: 'dynamic',
}),
],
}// React — vite.config.ts
import react from '@vitejs/plugin-react'
import fluentiReact from '@fluenti/react/vite-plugin'
export default {
plugins: [
fluentiReact({ splitting: 'dynamic' }),
react(),
],
}// Solid — vite.config.ts
import solidPlugin from 'vite-plugin-solid'
import fluentiSolid from '@fluenti/solid/vite-plugin'
export default {
plugins: [
solidPlugin(),
fluentiSolid({ splitting: 'dynamic' }),
],
}Plugin Options
All framework plugins accept the same options:
interface FluentiPluginOptions {
/** Directory containing compiled message catalogs.
* @default 'src/locales/compiled' */
catalogDir?: string
/** The source (default) locale.
* @default 'en' */
sourceLocale?: string
/** All available locales.
* @default [sourceLocale] */
locales?: string[]
/** Code splitting strategy.
* @default false */
splitting?: 'dynamic' | 'static' | false
/** Locale used for static build-time inlining.
* @default sourceLocale */
defaultBuildLocale?: string
}What It Provides
For framework package authors, this package exports:
createFluentiPlugins(options, frameworkPlugins, runtimeGenerator)— factory function to build the Vite plugin pipelineFluentiPluginOptions— user-facing options typeRuntimeGenerator/RuntimeGeneratorOptions— interface for framework-specific virtual module runtime generation
Code Splitting
| Strategy | Behavior | Best For |
|----------|----------|----------|
| 'dynamic' | Default locale loaded statically; others lazy-loaded on switchLocale() | SPAs with multiple locales |
| 'static' | All messages for a single locale inlined at build time | SSR, static site generation |
| false | All messages bundled in a single chunk | Small apps, simple setups |
Peer Dependencies
vite^5, ^6, or ^8
Documentation
Full documentation at fluenti.dev.
