Skip to content
Kona

Asset bundling with Vite

Kona’s Vite helper lives in kona-crema (org.konaframework.crema.assets) and is shared with Inertia (org.konaframework.inertia.assets remains a thin facade). It reads the standard Vite build output and optional hot file so Crema @vite directives and Inertia shells emit the right tags in development and production.

public/
hot # optional: full URL of the Vite dev server
build/
manifest.json # Vite manifest (npm run build)
assets/…
Vite.tags("src/main/resources/js/app.js")
// production:
// <link rel="stylesheet" href="/build/assets/app.css">
// <script type="module" src="/build/assets/app.js"></script>

When public/hot exists (contents like http://127.0.0.1:5173), tags point at the Vite server instead:

<script type="module" src="http://127.0.0.1:5173/@vite/client"></script>
<script type="module" src="http://127.0.0.1:5173/src/main/resources/js/app.js"></script>

Resolve a single URL:

Vite.asset("src/main/resources/js/app.js") // /build/assets/… or hot URL

CremaServiceProvider and InertiaServiceProvider bind AssetManifest to vite.public_path / inertia.public_path (default <base>/public) and set the Vite facade. Crema @vite('…') uses that resolver when bound, otherwise falls back to /build/… paths.

Terminal window
./grind assets:vite

Prints the same setup checklist (no processes are started).

{
"scripts": {
"dev": "vite",
"build": "vite build"
}
}

Point Vite’s build.outDir at public/build and enable build.manifest: true. The Inertia starter kit (kona new … --kit=inertia) includes package.json and vite.config.js stubs.

With inertia.root_view set, the HTML shell receives a vite string you can print with {!! vite !!}. Default entry: src/main/resources/js/app.js (InertiaManager.viteEntries).