Skip to content

API > wxt > WxtHooks

Interface: WxtHooks

Contents

Properties

build:before

build:before: (wxt) => HookResult

Called before the build is started in both dev mode and build mode.

Parameters

wxt: Wxt

The configured WXT object

Source

packages/wxt/src/types.ts:1074


build:done

build:done: (wxt, output) => HookResult

Called once the build process has finished. You can add files to the build summary here by pushing to output.publicAssets.

Parameters

wxt: Wxt

The configured WXT object

output: Readonly<BuildOutput>

The results of the build

Source

packages/wxt/src/types.ts:1082


build:manifestGenerated

build:manifestGenerated: (wxt, manifest) => HookResult

Called once the manifest has been generated. Used to transform the manifest by reference before it is written to the output directory.

Parameters

wxt: Wxt

The configured WXT object

manifest: WebExtensionManifest

The manifest that was generated

Source

packages/wxt/src/types.ts:1089


build:publicAssets

build:publicAssets: (wxt, files) => HookResult

Called when public assets are found. You can modify the files list by reference to add or remove public files.

Parameters

wxt: Wxt

The configured WXT object

files: ResolvedPublicFile[]

Source

packages/wxt/src/types.ts:1111


entrypoints:grouped

entrypoints:grouped: (wxt, groups) => HookResult

Called once all entrypoints have been grouped into their build groups.

Parameters

wxt: Wxt

The configured WXT object

groups: EntrypointGroup[]

Source

packages/wxt/src/types.ts:1104


entrypoints:resolved

entrypoints:resolved: (wxt, entrypoints) => HookResult

Called once all entrypoints have been loaded from the entrypointsDir.

Parameters

wxt: Wxt

The configured WXT object

entrypoints: Entrypoint[]

The list of entrypoints to be built

Source

packages/wxt/src/types.ts:1098


prepare:publicPaths

prepare:publicPaths: (wxt, paths) => HookResult

Called before generating the list of public paths inside .wxt/types/paths.d.ts. Use this hook to add additional paths (relative to output directory) WXT doesn't add automatically.

Parameters

wxt: Wxt

The configured WXT object

paths: string[]

This list of paths TypeScript allows browser.runtime.getURL to be called with.

Returns

Example

ts
wxt.hooks.hook('prepare:publicPaths', (wxt, paths) => {
  paths.push('/icons/128.png');
})

Source

packages/wxt/src/types.ts:1068


prepare:types

prepare:types: (wxt, entries) => HookResult

Called before WXT writes .wxt/tsconfig.json and .wxt/wxt.d.ts, allowing addition of custom references and declarations in wxt.d.ts, or directly modifying the options in tsconfig.json.

Parameters

wxt: Wxt

entries: WxtDirEntry[]

Returns

Example

ts
wxt.hooks.hook("prepare:types", (wxt, entries) => {
  // Add a file, ".wxt/types/example.d.ts", that defines a global
  // variable called "example" in the TS project.
  entries.push({
    path: "types/example.d.ts",
    textContent: "declare const a: string;",
    tsReference: true,
  });
})

Source

packages/wxt/src/types.ts:1054


ready

ready: (wxt) => HookResult

Called after WXT initialization, when the WXT instance is ready to work.

Parameters

wxt: Wxt

The configured WXT object

Returns

Promise

Source

packages/wxt/src/types.ts:1037


vite:build:extendConfig

vite:build:extendConfig: (entrypoints, viteConfig) => HookResult

Called when WXT has created Vite's config for a build step. Useful if you want to add plugins or update the vite config per entrypoint group.

Parameters

entrypoints: readonly Entrypoint[]

The list of entrypoints being built with the provided config.

viteConfig: InlineConfig

The config that will be used for the dev server.

Source

packages/wxt/src/types.ts:400


vite:devServer:extendConfig

vite:devServer:extendConfig: (config) => HookResult

Called when WXT has created Vite's config for the dev server. Useful if you want to add plugins or update the vite config per entrypoint group.

Parameters

config: InlineConfig

Source

packages/wxt/src/types.ts:410


Generated using typedoc-plugin-markdown and TypeDoc