extension.config.js (or .mjs / .cjs) from your project root. It applies settings to every command and the bundler.
How it works
Addextension.config.js at your project root (same level as package.json in typical setups).
Supported file names:
extension.config.jsextension.config.mjsextension.config.cjs
Type-safe configuration
Extension.js exports theFileConfig type from the extension package so editors can autocomplete and type-check your config. Annotate the export with a JSDoc @type tag — it works in extension.config.js, .mjs, and .cjs without a build step:
Environment loading for configuration files
extension.config.* runs in Node and should read values from process.env.*.
- Extension.js preloads env files before evaluating
extension.config.*. - It first checks the project folder.
- In monorepos, if Extension.js finds no project-local
.env*file, it falls back to the nearest workspace root. The workspace root is the folder containingpnpm-workspace.yaml. - Prefer built-in env preload over importing
dotenvin your configuration file.
Browser configuration
Need different browser defaults per target? Usebrowser:
chrome, edge, firefox, chromium, chromium-based, gecko-based, firefox-based.
Common browser fields:
profile,persistProfilepreferencesbrowserFlags,excludeBrowserFlagschromiumBinary,geckoBinaryextensions(companion load-only extensions)
Browser target capabilities
Commands configuration
Usecommands to define defaults per command:
- Extension.js merges top-level
extensionsandtranspilePackagesinto command defaults. - Per-command values override top-level values.
- The
startcommand runsbuildthenpreviewinternally. Extension.js applies settings fromcommands.start, including browser-launch options likeprofile,browserFlags, andstartingUrl. You can also put build-specific settings incommands.build.
Command capabilities (shared)
build command capabilities
dev command capabilities
Logging capabilities
Rspack configuration
Need advanced bundler customization? Useconfig to patch the generated Rspack configuration:
config may also be an object, which Extension.js merges on top of the generated config.
Full sample
Best practices
- Keep browser-specific values in
browser: Keep command definitions focused on workflow, not browser internals. - Use top-level defaults intentionally: Put shared
extensions/transpilePackagesat root; override only where needed. - Prefer
chromiumBinary/geckoBinarynames: They align with current command and type surface. - Keep
confighook minimal: Add only what first-class Extension.js options do not cover.
Next steps
- Learn more about Browsers available.
- Learn more about Rspack configuration.
- Tune launch behavior with Browser flags and Browser preferences.
- Manage env values with Environment variables.

