Skip to content

09 — Production deploy ​

Install the Vite plugin, set optimize: 'auto', deploy. That's it.

Install ​

bash
npm install -D vite-plugin-flexium

vite.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() → createSignal substitution — AST transform drops per-call cost from ~550 ns → ~13 ns on safe sites
  • Production devtools strip — import.meta.env.DEV guards folded to false, devtools code path eliminated

Available modes ​

ModePasses
'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
# → 0

The plugin ships a regression test that fails CI if devtools strings sneak into the production bundle.

Runtime size ​

  • flexium base: 12.56 KB gzipped
  • vite-plugin-flexium itself: 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-flexium with optimize: '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.

Released under the MIT License.