Rspack is a Rust-based JavaScript bundler with a webpack-compatible API, built as a drop-in replacement for webpack with much faster builds. Teams with existing webpack configurations get that speedup without rewriting their setup. The @nx/rspack plugin adds caching, affected builds, and task inference so Rspack scales across a monorepo.
What is Rspack?
Section titled “What is Rspack?”Rspack is a bundler written in Rust that implements the webpack API. Per the Rspack team's benchmarks (as of Rspack 2), it builds and serves projects several times faster than webpack. In a monorepo those savings compound, and Nx layers caching and affected-only builds on top so unchanged projects don't build at all.
Is Rspack a drop-in replacement for webpack?
Section titled “Is Rspack a drop-in replacement for webpack?”Mostly - existing loaders and the majority of webpack plugins run unchanged, so many configurations migrate with few or no edits. Plugins that depend on webpack internals may not work, so test complex setups when you migrate.
Requirements
Section titled “Requirements”The @nx/rspack plugin supports Rspack 1 and 2 (as of Nx v23).
| Package | Supported Versions | Default Installed |
|---|---|---|
@rspack/core | ^1.0.0 || ^2.0.0 | 2.0.4 |
Nx generators install the latest supported version automatically when scaffolding new projects. When @rspack/core is already installed in your workspace, generators detect the installed version and keep it in place rather than overwriting it.
Setting up @nx/rspack
Section titled “Setting up @nx/rspack”Installation
Section titled “Installation”In any Nx workspace, you can install @nx/rspack by running the following command:
nx add @nx/rspackThis will install the correct version of @nx/rspack.
How @nx/rspack infers tasks
Section titled “How @nx/rspack infers tasks”The @nx/rspack plugin will create a task for any project that has a Rspack configuration file present. Any of the following files will be recognized as a Rspack configuration file:
rspack.config.jsrspack.config.tsrspack.config.mjsrspack.config.mtsrspack.config.cjsrspack.config.cts
View inferred tasks
Section titled “View inferred tasks”To view inferred tasks for a project, open the project details view in Nx Console or run nx show project my-project --web in the command line.
@nx/rspack configuration
Section titled “@nx/rspack configuration”The @nx/rspack/plugin is configured in the plugins array in nx.json.
{ "plugins": [ { "plugin": "@nx/rspack/plugin", "options": { "buildTargetName": "build", "previewTargetName": "preview", "serveTargetName": "serve", "serveStaticTargetName": "serve-static" } } ]}The buildTargetName, previewTargetName, serveTargetName and serveStaticTargetName options control the names of the inferred Rspack tasks. The default names are build, preview, serve and serve-static.
Using @nx/rspack
Section titled “Using @nx/rspack”Generate a new project using Rspack
Section titled “Generate a new project using Rspack”You can generate a React application that uses Rspack. The @nx/react:app generator accepts the bundler option, where you can pass rspack. This will generate a new application configured to use Rspack, and it will also install all the necessary dependencies, including the @nx/rspack plugin.
To generate a React application using Rspack, run the following:
nx g @nx/react:app my-app --bundler=rspackModify an existing React project to use Rspack
Section titled “Modify an existing React project to use Rspack”You can use the @nx/rspack:configuration generator to change your React project to use Rspack. This generator will modify your project's configuration to use Rspack, and it will also install all the necessary dependencies, including the @nx/rspack plugin.
You can read more about this generator on the @nx/rspack:configuration generator page.
Why use Rspack in a monorepo?
Section titled “Why use Rspack in a monorepo?”Rspack speeds up each build, and Nx cuts down how many builds run. In a monorepo with many Rspack projects:
- Caching skips builds whose inputs haven't changed, locally and in CI.
nx affectedrebuilds and retests only the projects a change touches.- Because the API is webpack-compatible, you can migrate webpack projects to Rspack one at a time instead of converting every configuration in the repo at once.
For a complete pipeline, see Set up CI.