Skip to main content
Create production extension artifacts for one or more browser targets. build compiles your extension in production mode and writes output to dist/<browser>. For monorepo/submodule projects, see Environment variables for configuration-time env resolution (project root first, then workspace-root fallback).

When to use build

  • Preparing extension packages for Chrome Web Store, Edge Add-ons, or Firefox Add-ons.
  • Running continuous integration (CI) jobs that produce repeatable production artifacts.
  • Validating production bundle output and browser-target differences before submission.

Build command capabilities

Usage

Build output

After running build, Extension.js generates optimized files for the selected browser targets. Output goes to dist/ with one subfolder per target. Each folder contains bundled JavaScript, CSS, HTML, and required runtime assets.
For TypeScript projects, build also regenerates the extension-env.d.ts ambient type declarations (the same file dev writes), so a CI tsc --noEmit stays clean whether or not you ran dev first. JavaScript-only projects skip this step.
Example output structure:

Browser target matrix

What engine targets mean for build

build never launches a browser, so engine targets don’t point at a binary here, but they still produce a distinct artifact, not a renamed copy of a named-target build:
  • Own output folder. --browser=chromium-based writes to dist/chromium-based, the same folder dev, preview, and start use for that target, so a project developed against a custom Chromium binary builds to matching paths.
  • Own env resolution. .env.chromium-based and .env.chromium-based.production win over the family’s .env.chromium/.env.chrome/.env.edge, and bundled code sees EXTENSION_BROWSER === "chromium-based", so code and config can branch on β€œgeneric Chromium” vs a specific store build.
  • Own manifest prefix. chromium-based: keys in manifest.json resolve as the most-specific match for this target, on top of the family-wide chrome:/chromium:/edge: keys.
gecko-based works the same way relative to firefox. No browser binary is required, and --chromium-binary/--gecko-binary only matter for commands that launch a browser.

Arguments and flags

Shared global options

Also supports Global flags.

Mode override

--mode overrides the bundler mode and NODE_ENV for the build. Accepts development, production, or none. Use it to mirror Vite/webpack workflows where you need a non-production bundle for staging or debugging.
Invalid values exit with an error; the default remains production.

Zip behavior

Examples

Building with zip output and custom filename

In this example, the build targets Edge and Chrome, zips the output, and saves it as my-extension.zip.

Building with polyfill support

In this example, the build targets Chrome and Firefox and includes polyfill support where relevant.

Building source and artifact zip

Best practices

  • Check build logs: Review logs for warnings and missing assets after each build.
  • Optimize your manifest: Keep manifest.json compatible with every target browser.
  • Name artifacts intentionally: Use --zip-filename for stable CI artifact naming.
  • Validate target output: Check each dist/<browser> folder before publishing.

Next steps