Configuration

The wvb.config file that the CLI and the programmatic API read for pack, remote, serve, and builtin options.

A single wvb.config file drives every Webview Bundle workflow. Both the wvb CLI and the programmatic API (@wvb/cli/api) load it, so one config keeps packing, serving, remote publishing, and builtin installs consistent. Author it with defineConfig from @wvb/config to get full type-checking and editor autocompletion.

Each top-level section has its own page:

The config file

Place the config in your project root. The CLI auto-discovers the first matching file in the working directory, in this order:

wvb.config.js
wvb.config.cjs
wvb.config.mjs
wvb.config.ts
wvb.config.cts
wvb.config.mts
webview-bundle.config.js
webview-bundle.config.cjs
webview-bundle.config.mjs
webview-bundle.config.ts
webview-bundle.config.cts
webview-bundle.config.mts
wvb.config.json
wvb.config.jsonc

Both base names wvb.config.* and webview-bundle.config.* are supported with the .js, .cjs, .mjs, .ts, .cts, and .mts extensions. The .json and .jsonc forms are only recognized for the wvb.config base name. Pass --config (alias -C) to any command to point at a specific file instead of relying on discovery.

wvb pack --config ./configs/wvb.prod.ts

defineConfig

Wrap your config with defineConfig from @wvb/config. It is an identity function at runtime — its only job is to attach types. It accepts an object, a promise that resolves to a config, or a synchronous or asynchronous function that returns one, so you can compute values at load time.

wvb.config.ts
import { defineConfig } from '@wvb/config';

export default defineConfig({
  root: process.cwd(),
  pack: {
    srcDir: './dist',
  },
  serve: {
    port: 4312,
  },
});
wvb.config.ts
import { defineConfig } from '@wvb/config';

export default defineConfig(async () => {
  const endpoint = process.env.WVB_ENDPOINT;
  return {
    remote: {
      endpoint,
    },
  };
});

Install the package as a dev dependency: npm install -D @wvb/config.

Top-level fields

The config object has five optional fields. Nothing else is read at the top level.

FieldTypeDefault
rootstringprocess.cwd()
packPackConfig
remoteRemoteConfig
serveServeConfig
builtinBuiltinConfig

root sets the project root used to resolve relative paths. It may be absolute or relative to the config file. Each section field is documented on its own page linked above.

On this page