extension.config.jsCustomize bundling behavior without leaving the Extension.js workflow.
Solve custom bundler needs (loaders, plugins, aliases) without forking the default setup. Extension.js builds with Rspack (@rspack/core) and lets you extend the generated config directly.
Create one of these files at project root:
extension.config.jsextension.config.mjsextension.config.cjsUse the config key to patch generated bundler config.
config capabilities| Capability | What it does |
|---|---|
Function hook (config: (config) => config) |
Gives full control to read and modify generated Rspack config before build. |
Object merge (config: { ... }) |
Merges additional config into the generated base config. |
Rules (config.module.rules) |
Adds or changes loader rules for file types. |
Plugins (config.plugins) |
Adds compile-time plugins and transformations. |
Resolve (config.resolve) |
Adds aliases and module resolution behavior. |
config can also be an object. Extension.js merges it into the base config.
Extension.js is Rspack-native, but much of the webpack ecosystem is still usable.
@rspack/core Configuration.Example using a Rspack-native plugin:
browser / commands config keys before low-level bundler overrides.dev, start, preview, and build for your browser matrix after config changes.extension.config.js).