Skip to content

Build Options

The build block configures the production build — minification, source maps, output naming, directory cleanup, and library mode. The underlying bundler (Rolldown) is an internal detail and is never exposed: there is no rolldownOptions escape hatch.

For a task-oriented guide, see Building for Production.

ts
import { defineConfig } from "vantris";

export default defineConfig({
  build: {
    minify: true,
    sourcemap: false,
    emptyOutDir: true,
    assetsDir: "assets",
    entryFileNames: "assets/[name]-[hash].js",
    chunkFileNames: "assets/[name]-[hash].js",
    assetFileNames: "assets/[name]-[hash][extname]",
    // lib: { ... }
  },
});

build.minify

  • Type: boolean
  • Default: true

Minify the output. Turn it off to inspect readable build output.

ts
build: { minify: false }

build.sourcemap

  • Type: boolean | "inline" | "hidden"
  • Default: false

Source map strategy — covers JavaScript, TypeScript, and CSS.

ValueResult
falseNo source maps.
trueSeparate .map files + a //# sourceMappingURL comment.
"inline"Map appended to each file as a data URL.
"hidden"Separate .map files, no comment.
ts
build: { sourcemap: true }

build.emptyOutDir

  • Type: boolean
  • Default: true

Empty the output directory before building. The clean is guarded so it can never remove anything outside outDir.

ts
build: { emptyOutDir: false } // keep existing files (rare)

build.assetsDir

  • Type: string
  • Default: "assets"

Directory (relative to outDir) for built chunks and assets. It's used to derive the default *FileNames patterns below — change it and the defaults follow.

ts
build: { assetsDir: "static" }
// → entryFileNames defaults to "static/[name]-[hash].js"

build.entryFileNames

  • Type: string | ((chunk: ChunkInfo) => string)
  • Default: `${assetsDir}/[name]-[hash].js`

Naming pattern for entry chunks. A string with [name], [hash], [ext], [extname] placeholders, or a function receiving ChunkInfo.

ts
build: { entryFileNames: "js/[name]-[hash].js" }
ts
build: { entryFileNames: (chunk) => `js/${chunk.name}.[hash].js` }

build.chunkFileNames

  • Type: string | ((chunk: ChunkInfo) => string)
  • Default: `${assetsDir}/[name]-[hash].js`

Naming pattern for shared/dynamic chunks (code splitting). String or a function receiving ChunkInfo.

build.assetFileNames

  • Type: string | ((asset: AssetInfo) => string)
  • Default: `${assetsDir}/[name]-[hash][extname]`

Naming pattern for emitted assets (images, fonts, …). String or a function receiving AssetInfo.

ts
build: { assetFileNames: (asset) => `media/${asset.names[0]}` }

build.lib

Build a library instead of an HTML application. When set, the HTML pipeline is skipped and the entry is emitted in each requested format. See Library Mode.

ts
build: {
  lib: {
    entry: "./src/index.ts",
    name: "MyLibrary",
    formats: ["esm", "cjs", "iife"],
  },
}

LibConfig

FieldTypeDefaultDescription
entrystringEntry module (relative to root/absolute).
namestringGlobal name — required for iife.
formats("esm" | "cjs" | "iife")[]["esm", "cjs"]Formats to emit, one file each.
fileNamestring | ((format: LibFormat) => string)entry base nameOutput name (extension derived per format).

Extensions per format: .mjs (esm), .cjs (cjs), .iife.js (iife).

Types

ChunkInfo

Passed to a entryFileNames/chunkFileNames function — a Vantris-owned, stable subset of the bundler's pre-render data:

ts
interface ChunkInfo {
  name: string;              // chunk name used in naming patterns
  isEntry: boolean;          // static entry chunk?
  isDynamicEntry: boolean;   // dynamic-import entry chunk?
  facadeModuleId: string | null; // absolute id of the module this chunk represents
  moduleIds: string[];       // absolute ids of the modules included
  exports: string[];         // names exported by this chunk
}

AssetInfo

Passed to an assetFileNames function:

ts
interface AssetInfo {
  names: string[];             // candidate names for the asset
  originalFileNames: string[]; // absolute paths of the source files
}

Reserved for future versions

The interface is shaped to grow without breaking existing configs. Options like target, manifest, and build plugins are declared as a contract in the source but not yet active. There will never be a rolldownOptions escape hatch — new output options are added as first-class, Vantris-typed fields.

Released under the MIT License.