@nx/rspack

The Nx plugin for Rspack.

Rspack is a fast build tool written in Rust that is interoperable with the Webpack ecosystem.

Why should you use this plugin?

  • Instant dev server start
  • Lightning fast Hot-Module Reloading
  • Fast builds using Rspack.
  • Out-of-the-box support for TypeScript, JSX, CSS, and more.
  • Compatible with the Webpack ecosystem.

Read more about it in the Rspack documentation.

Setting up a new Nx workspace with Rspack

You can create a new React workspace that uses Rspack using this command:

npx create-nx-workspace@latest --preset=@nx/rspack

Nx 15 and lower use @nrwl/ instead of @nx/

You will be prompted for a repository name, which will be used for the folder and application name.

Add Rspack to an existing workspace

There are a number of ways to use Rspack in your existing workspace.

First, make sure @nx/rspack is installed.

1npm i -D @nx/rspack@latest 2
Nx 15 and lower use @nrwl/ instead of @nx/

Generate a new React project using Rspack

The easiest way to generate a new application that uses Rspack is by using the @nx/rspack:app generator.

1nx g @nx/rspack:app my-app --style=css 2
Nx 15 and lower use @nrwl/ instead of @nx/

Then you should be able to serve, test, and build the application.

1nx serve my-app 2nx test my-app 3nx build my-app 4

Generate a non-React project using Rspack

You can generate a Web application, and then use the @nx/rspack:configuration generator to configure the build and serve targets.

Make sure you have the Web plugin installed.

1npm i -D @nrwl/web@latest 2

Then generate the application.

1nx g @nrwl/web:app my-app --style=css 2

Finally, configure Rspack for the new project.

1nx g @nx/rspack:configuration --project=my-app 2
Nx 15 and lower use @nrwl/ instead of @nx/

Modify an existing React or Web project to use Rspack

You can use the @nx/rspack:configuration generator to change your React or Web project to use Rspack. This generator will modify your project's configuration to use Rspack, and it will also install all the necessary dependencies.

You can read more about this generator on the @nx/rspack:configuration generator page.

Initialize Rspack

If you do not want to create any new projects or convert any existing projects yet, you can still use Nx to install all the necessary dependencies for Rspack. This, for example, could be useful if you want to set up Rspack manually for a project.

Package reference

Here is a list of all the executors and generators available from this package.

Guides

Executors

Generators