Skip to content

API / wxt/modules / addEntrypoint

Function: addEntrypoint()

addEntrypoint(wxt, entrypoint): void

Source: packages/wxt/src/modules.ts:56

Adds a TS/JS file as an entrypoint to the project. This file will be bundled along with the other entrypoints.

If you're publishing the module to NPM, you should probably pre-build the entrypoint and use addPublicAssets instead to copy pre-bundled assets into the output directory. This will speed up project builds since it just has to copy some files instead of bundling them.

To extract entrypoint options from a JS/TS file, use wxt.builder.importEntrypoint (see example).

Parameters

wxt

Wxt

The wxt instance provided by the module's setup function.

entrypoint

Entrypoint

The entrypoint to be bundled along with the extension.

Returns

void

Example

ts
export default defineWxtModule(async (wxt, options) => {
    const entrypointPath = '/path/to/my-entrypoint.ts';
    addEntrypoint(wxt, {
      type: 'content-script',
      name: 'some-name',
      inputPath: entrypointPath,
      outputDir: wxt.config.outDir,
      options: await wxt.builder.importEntrypoint(entrypointPath),
    });
  });

Generated using typedoc-plugin-markdown and TypeDoc