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:1396


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:1404


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: Manifest

The manifest that was generated

Source ​

packages/wxt/src/types.ts:1412


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:1448


config:resolved ​

config:resolved: (wxt) => HookResult

Called whenever config is loaded or reloaded. Use this hook to modify config by modifying wxt.config.

Parameters ​

▪ wxt: Wxt

The configured WXT object

Source ​

packages/wxt/src/types.ts:1338


entrypoints:found ​

entrypoints:found: (wxt, infos) => HookResult

Called once the names and paths of all entrypoints have been resolved.

Parameters ​

▪ wxt: Wxt

The configured WXT object

▪ infos: EntrypointInfo[]

List of entrypoints found in the project's entrypoints directory

Source ​

packages/wxt/src/types.ts:1423


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:1439


entrypoints:resolved ​

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

Called once all entrypoints have been loaded from the entrypointsDir. Use wxt.builder.importEntrypoint to load entrypoint options from the file, or manually define them.

Parameters ​

▪ wxt: Wxt

The configured WXT object

▪ entrypoints: Entrypoint[]

The list of entrypoints to be built

Source ​

packages/wxt/src/types.ts:1432


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.

Example ​

ts
wxt.hooks.hook('prepare:publicPaths', (wxt, paths) => {
    paths.push('icons/128.png');
    paths.push({
      type: 'templateLiteral',
      path: '_favicon/?${string}',
    });
  });

Parameters ​

▪ wxt: Wxt

The configured WXT object

▪ paths: PublicPathEntry[]

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

Source ​

packages/wxt/src/types.ts:1390


prepare:tsconfig ​

prepare:tsconfig: (wxt, configs) => HookResult

Called before WXT writes your tsconfig to the disk, allowing full customization by modifying the object by reference.

Since ​

0.20.28

Example ​

ts
wxt.hooks.hook('prepare:tsconfig', (wxt, { tsconfig }) => {
    tsconfig.compilerOptions.lib.push('WebWorker');
  });

Parameters ​

▪ wxt: Wxt

▪ configs: PrepareTsconfigs

Source ​

packages/wxt/src/types.ts:1371


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.

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',
      text: 'declare const a: string;',
      tsReference: true,
    });
    // use module to add Triple-Slash Directive in .wxt/wxt.d.ts
    // eg: /// <reference types="@types/example" />
    entries.push({
      module: '@types/example',
    });
  });

Parameters ​

▪ wxt: Wxt

▪ entries: WxtDirEntry[]

Source ​

packages/wxt/src/types.ts:1360


ready ​

ready: (wxt) => HookResult

Called after WXT modules are initialized, when the WXT instance is ready to be used. wxt.server isn't available yet, use server:created to get it.

Parameters ​

▪ wxt: Wxt

The configured WXT object

Source ​

packages/wxt/src/types.ts:1331


server:closed ​

server:closed: (wxt, server) => HookResult

Called when the dev server is stopped.

Parameters ​

▪ wxt: Wxt

The configured WXT object

▪ server: WxtDevServer

Same as wxt.server, the object WXT uses to control the dev server.

Source ​

packages/wxt/src/types.ts:1512


server:created ​

server:created: (wxt, server) => HookResult

Called when the dev server is created (and wxt.server is assigned). Server has not been started yet.

Parameters ​

▪ wxt: Wxt

The configured WXT object

▪ server: WxtDevServer

Same as wxt.server, the object WXT uses to control the dev server.

Source ​

packages/wxt/src/types.ts:1496


server:started ​

server:started: (wxt, server) => HookResult

Called when the dev server is started.

Parameters ​

▪ wxt: Wxt

The configured WXT object

▪ server: WxtDevServer

Same as wxt.server, the object WXT uses to control the dev server.

Source ​

packages/wxt/src/types.ts:1504


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:532


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:543


zip:done ​

zip:done: (wxt, zipFiles) => HookResult

Called after the entire zip process is complete.

Parameters ​

▪ wxt: Wxt

The configured WXT object

▪ zipFiles: string[]

An array of paths to all created zip files

Source ​

packages/wxt/src/types.ts:1487


zip:extension:done ​

zip:extension:done: (wxt, zipPath) => HookResult

Called after zipping the extension files.

Parameters ​

▪ wxt: Wxt

The configured WXT object

▪ zipPath: string

The path to the created extension zip file

Source ​

packages/wxt/src/types.ts:1467


zip:extension:start ​

zip:extension:start: (wxt) => HookResult

Called before zipping the extension files.

Parameters ​

▪ wxt: Wxt

The configured WXT object

Source ​

packages/wxt/src/types.ts:1460


zip:sources:done ​

zip:sources:done: (wxt, zipPath) => HookResult

Called after zipping the source files (for Firefox).

Parameters ​

▪ wxt: Wxt

The configured WXT object

▪ zipPath: string

The path to the created sources zip file

Source ​

packages/wxt/src/types.ts:1480


zip:sources:start ​

zip:sources:start: (wxt) => HookResult

Called before zipping the source files (for Firefox).

Parameters ​

▪ wxt: Wxt

The configured WXT object

Source ​

packages/wxt/src/types.ts:1473


zip:start ​

zip:start: (wxt) => HookResult

Called before the zip process starts.

Parameters ​

▪ wxt: Wxt

The configured WXT object

Source ​

packages/wxt/src/types.ts:1454


Generated using typedoc-plugin-markdown and TypeDoc