Building for Production
vantris build produces an optimised production bundle in outDir. It's powered by Rolldown — tree shaking, minification, code splitting, and content-hashed output — but Rolldown is never exposed: every option is Vantris-owned.
vantris build # → dist/What a build does
- Cleans
outDir(guarded so it can never remove anything outside it). - Analyses
index.htmlfor<script type="module">entries (multiple supported). - Bundles with Rolldown — tree shaking, minification, code splitting.
- Rewrites
dist/index.htmlto point at the hashed output. - Copies
public/verbatim.
The mode defaults to production. Override with --mode.
HTML processing
The build treats index.html as the entry graph. What gets processed:
- JS-imported assets (
import url from "./logo.svg") → hashed files with absolute URLs derived frombase. - CSS (
import "./style.css") → processed with lightningcss, emitted as a hashed.csswith a<link>injected. Includesurl()rewriting,@importinlining, CSS Modules, Sass/Less, PostCSS, and CSS code splitting for lazy chunks. See CSS. - HTML
src/hrefin<link>/<img>/<script>that point intorootDir→ hashed and rewritten. Public and external references are left untouched.
Output naming
Built files are content-hashed by default so they cache forever and bust on change. The patterns are configurable and each accepts a string pattern or a function:
export default defineConfig({
build: {
assetsDir: "assets", // drives the defaults below
entryFileNames: "assets/[name]-[hash].js",
chunkFileNames: "assets/[name]-[hash].js",
assetFileNames: "assets/[name]-[hash][extname]",
},
});build: {
entryFileNames: (chunk) => `js/${chunk.name}.[hash].js`,
assetFileNames: (asset) => `media/${asset.names[0]}`,
}The placeholders are [name], [hash], [ext], and [extname]. See Build Options for ChunkInfo/AssetInfo.
Minification
On by default. Turn it off to inspect the output:
build: { minify: false }Source maps
build.sourcemap covers JavaScript, TypeScript, and CSS:
| Value | Result |
|---|---|
false | No maps (default). |
true | External .map files + a sourceMappingURL comment. |
"inline" | Map embedded as a base64 data URL. |
"hidden" | External .map files, no comment. |
build: { sourcemap: true }The base path
base is applied consistently across HTML, CSS url(), injected stylesheets, and JS-imported assets. Dynamic-import chunks stay relative, so they resolve correctly under any base.
export default defineConfig({
base: "/my-app/", // deploy under a sub-path
});export default defineConfig({
base: "https://cdn.example.com/assets/", // or a CDN
});Watch mode
vantris build --watch (or -w) rebuilds on every change, debounced. It does not start a dev server — it only rebuilds — and a failed build never stops the watcher.
vantris build --watchUse it when a separate process (an Electron shell, a backend serving dist/) consumes the build output and you want it kept fresh.
define — inlined constants
define replaces identifiers with a JSON literal everywhere they appear, in both dev and build. Dead branches guarded by an inlined false are tree-shaken away:
export default defineConfig({
define: { __DEV__: false, __APP_VERSION__: "1.0.0" },
});if (__DEV__) console.log("dev only"); // dropped in production
console.log(__APP_VERSION__); // → console.log("1.0.0")See Define / Global Constants.
Assets
Images, fonts, media, wasm, and txt resolve to hashed URLs when imported; json is imported as data. They behave identically in dev and build. See Static Assets.
Building a library instead
Set build.lib to bundle a single entry into esm + cjs + iife instead of an HTML app. The HTML pipeline is skipped. See Library Mode.
Then preview it
vantris build && vantris previewvantris preview serves the finished dist/ with no compilation — the closest local mirror of production. See Preview.
The internal cache
The build reuses Vantris's transparent cache in node_modules/.vantris/ for build metadata; it's wiped automatically when the Vantris version or your config changes. See Internal Cache.