09 — Production deploy
Install the Vite plugin, set optimize: 'auto', deploy. That's it.
Install
bash
npm install -D vite-plugin-flexiumvite.config.ts
ts
import { defineConfig } from 'vite'
import flexium from 'vite-plugin-flexium'
export default defineConfig({
plugins: [
flexium({
optimize: 'auto' // enables compile-time passes
})
]
})That single flag enables:
- Static JSX hoisting — pure-literal
<div>subtrees lifted to module scope, allocated once, reused per render - CSS pre-compute — static
css({...})calls extracted to build-time hashed class strings use()→createSignalsubstitution — AST transform drops per-call cost from ~550 ns → ~13 ns on safe sites- Production devtools strip —
import.meta.env.DEVguards folded tofalse, devtools code path eliminated
Available modes
| Mode | Passes |
|---|---|
'off' | Nothing — pass through |
'auto' (recommended) | static-lift, css-precompute, use-substitution |
'aggressive' | + component-inline + dead-code elimination |
Verify
After building, the production bundle should have:
- No
registerSignal(calls (devtools stripped) - No
__FLEXIUM_DEVTOOLS__references - Smaller bundle size (depends on app complexity)
bash
grep -c 'registerSignal\|__FLEXIUM_DEVTOOLS__' dist/assets/*.js
# → 0The plugin ships a regression test that fails CI if devtools strings sneak into the production bundle.
Runtime size
flexiumbase: 12.56 KB gzippedvite-plugin-flexiumitself: dev-time only, not shipped
Hosting
Flexium runs anywhere a static site or Node server runs:
- Vercel — full support
- Cloudflare Pages / Workers — works
- Netlify — works
- Self-host — output is plain static assets + an optional SSR Node entry point
For SSR, use renderToString from flexium/server in your Node server (Express, Hono, Fastify, etc.).
API surface used
vite-plugin-flexiumwithoptimize: 'auto' | 'aggressive' | 'off'
You're done
That's the tour. For the full API surface, see flexium on GitHub.
If you build something with flexium, add it to the showcase via PR.