Webview Bundle

Configuration reference

The wvb.config file — pack, remote, serve, and builtin options.

The wvb CLI reads a config file (wvb.config.ts, .js, .mjs, …) from the working directory. Author it with defineConfig from @wvb/config for full type-checking:

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

export default defineConfig({
  root: process.cwd(),
  pack: {
    /* … */
  },
  remote: {
    /* … */
  },
  serve: {
    /* … */
  },
  builtin: {
    /* … */
  },
});

defineConfig also accepts an async function or a promise, so you can compute config at runtime (e.g. read a version, load a signing key):

export default defineConfig(async () => ({
  remote: { endpoint: process.env.WVB_ENDPOINT! /* … */ },
}));

Top-level

FieldTypeDescription
rootstringProject root for resolving paths. Default process.cwd().
packPackConfigDefaults for wvb pack.
remoteRemoteConfigRemote server, uploader/deployer, integrity/signature.
serveServeConfigDefaults for wvb serve.
builtinBuiltinConfigDefaults for wvb builtin.

pack

pack: {
  srcDir: './dist',
  outFile: 'app',                 // → app.wvb
  outDir: '.wvb',
  ignore: ['*.map'],
  headers: { '*.html': { 'cache-control': 'max-age=3600' } },
  overwrite: true,
}
FieldTypeDescription
srcDirstringDirectory to pack.
outFilestringOutput file name (.wvb appended if missing).
outDirstringOutput directory. Default .wvb.
ignoreArray<string | RegExp> | ((file) => boolean)Patterns/predicate to exclude files.
headersRecord<glob, HeadersInit> | [glob, HeadersInit][] | ((file) => HeadersInit)HTTP headers to attach to matching files.
overwritebooleanOverwrite an existing output. Default true.

remote

import { localRemote } from '@wvb/remote-local';
const provider = localRemote({});

remote: {
  endpoint: 'https://updates.example.com',
  bundleName: 'app',              // or () => string | Promise<string>
  version: () => pkg.version,     // or a string; defaults to package.json version
  uploader: provider.uploader,
  deployer: provider.deployer,
  integrity: { algorithm: 'sha384' },
  signature: { /* see below */ },
}
FieldTypeDescription
endpointstringBase URL of the remote server.
bundleNamestring | (() => …)Bundle name for remote operations.
versionstring | (() => …)Version to publish.
uploaderBaseRemoteUploaderUploads the .wvb to the server (from a provider).
deployerBaseRemoteDeployerMarks a version deployed (from a provider).
integrityboolean | { algorithm }Compute an integrity hash on upload.
signatureSignatureSignConfig | fnSign the bundle on upload.

uploader/deployer come from a provider package — @wvb/remote-local, @wvb/remote-aws, or @wvb/remote-cloudflare. Each exposes { uploader, deployer } compatible with these fields.

integrity

Either true/{ algorithm } for the built-in hashing, or a function for custom logic.

integrity: {
  algorithm: 'sha384';
} // 'sha256' | 'sha384' | 'sha512'
integrity: async ({ data }) => `sha384:${await myHash(data)}`;

signature

Sign the integrity string with a private key. The algorithm determines the required fields:

// ECDSA
signature: {
  algorithm: 'ecdsa',
  curve: 'p256',                  // 'p256' | 'p384'
  hash: 'sha256',                 // 'sha256' | 'sha384' | 'sha512'
  key: { format: 'pkcs8', data: privateKeyDerBuffer },
}

// Ed25519
signature: {
  algorithm: 'ed25519',
  key: { format: 'pkcs8', data: privateKeyDerBuffer },
}

// RSA
signature: {
  algorithm: 'rsa-pss',           // or 'rsa-pkcs1-v1.5'
  hash: 'sha256',
  saltLength: 32,                 // rsa-pss only
  key: { format: 'pkcs8', data: privateKeyDerBuffer },
}

// or fully custom
signature: async ({ message }) => myExternalSigner(message),

Key format is one of 'raw' | 'pkcs8' | 'spki' | 'jwk' (use data: JsonWebKey for 'jwk', data: Buffer otherwise). Clients verify with the matching public key — see Remote updates → Integrity and signatures.

serve

serve: { file: './app.wvb', port: 4312, silent: false }
FieldTypeDescription
filestringBundle to serve.
portnumberPort. Default 4312.
silentbooleanDisable request logging.

builtin

builtin: {
  outDir: '.wvb/builtin/bundles',
  include: ['app*'],
  exclude: ['internal*'],
  clean: true,
}
FieldTypeDescription
outDirstringWhere to write downloaded builtin bundles. Default .wvb/builtin/bundles.
include / excludestring | RegExp | Array<…> | ((info) => boolean)Match remote bundles by name/version.
cleanbooleanClear outDir before downloading. Default true.
download.concurrencynumberParallel downloads.

On this page