close
logologo
Guide
Config
Plugin
API
Community
Version
Changelog
Rsbuild 0.x Doc
English
简体中文
Guide
Config
Plugin
API
Community
Changelog
Rsbuild 0.x Doc
English
简体中文
logologo

Getting Started

Introduction
Quick start
Features
Glossary

Framework

React
Vue
Preact
Svelte
Solid

Basic

CLI
Dev server
Output files
Static assets
HTML
JSON
Wasm
TypeScript
Web Workers
Deploy static site
Upgrade Rsbuild

Configuration

Configure Rspack
Configure Rsbuild
Configure SWC

Styling

CSS
CSS Modules
CSS-in-JS
Tailwind CSS v4
Tailwind CSS v3
UnoCSS

Advanced

Path aliases
Environment variables
Hot module replacement
Browserslist
Browser compatibility
Module Federation
Multi-environment builds
Server-side rendering (SSR)
Testing

Optimization

Code splitting
Bundle size optimization
Improve build performance
Inline static assets

Migration

Migrating from Rsbuild 0.x
webpack
Create React App
Vue CLI
Vite
Vite plugin
Modern.js Builder

Debug

Debug mode
Build profiling
Use Rsdoctor

FAQ

General FAQ
Features FAQ
Exceptions FAQ
HMR FAQ
📝 Edit this page on GitHub
Previous PageVite plugin
Next PageDebug mode

#Modern.js Builder

This chapter introduces how to migrate a Modern.js Builder (or EdenX Builder) project to Rsbuild.

#Key differences

Rsbuild is the new version of Modern.js Builder, with the following key differences:

  • Rsbuild has better performance. When using Rspack simultaneously, the startup speed and build speed of Rsbuild are 1.5 to 2 times faster than Builder.
  • Rsbuild only supports Rspack as the bundler and no longer supports webpack.
  • Rsbuild's CLI tool and dev server are more powerful and support more features.

#Installing dependencies

First, you need to replace the npm dependencies related to Builder with Rsbuild's dependencies.

  • Remove Builder's dependencies:
npm
yarn
pnpm
bun
npm remove @modern-js/builder-cli @modern-js/builder-webpack-provider @modern-js/builder-rspack-provider
  • Install Rsbuild's dependencies:
npm
yarn
pnpm
bun
npm add @rsbuild/core -D

#Updating npm scripts

Next, you need to update the npm scripts in the package.json to Rsbuild's CLI commands.

package.json
{
  "scripts": {
    "dev": "builder dev",
    "build": "builder build",
    "serve": "builder serve",
    "dev": "rsbuild dev",
    "build": "rsbuild build",
    "preview": "rsbuild preview"
  }
}

#Modifying configuration files

  • Rename builder.config.ts to rsbuild.config.ts.
  • Change the import of the defineConfig method from @modern-js/builder-cli to @rsbuild/core.
  • Change the builderPlugins field to plugins.
rsbuild.config.ts
import { defineConfig } from '@modern-js/builder-cli'; 
import { defineConfig } from '@rsbuild/core'; 

export default defineConfig({
  builderPlugins: [],
  plugins: [],
});

#Replacing plugins

Rsbuild and Builder have incompatible plugin systems, so you need to replace Builder's plugins with Rsbuild's plugins.

The following table shows the correspondence between Builder plugins and Rsbuild plugins:

BuilderRsbuild
@modern-js/builder-plugin-vue@rsbuild/plugin-vue
@modern-js/builder-plugin-vue2@rsbuild/plugin-vue2
@modern-js/builder-plugin-stylus@rsbuild/plugin-stylus
@modern-js/builder-plugin-node-polyfill@rsbuild/plugin-node-polyfill
@modern-js/builder-plugin-image-compress@rsbuild/plugin-image-compress
@modern-js/builder-plugin-swcEnabled by default, no need to use
@modern-js/builder-plugin-esbuildNo longer supported

For example, if you were using @modern-js/builder-plugin-vue, you need to first install @rsbuild/plugin-vue, then import the plugin in rsbuild.config.ts and add it to the plugins field.

rsbuild.config.ts
import { builderPluginVue } from '@modern-js/builder-plugin-vue'; 
import { pluginVue } from '@rsbuild/plugin-vue'; 

export default defineConfig({
  builderPlugins: [builderPluginVue()],
  plugins: [pluginVue()],
});

#Add React-related plugins

Rsbuild is not coupled with any front-end UI framework. Therefore, if you are a React project, you need to manually add React Plugin:

rsbuild.config.ts
import { pluginReact } from '@rsbuild/plugin-react';

export default {
  plugins: [pluginReact()],
};

If you are using SVGR in your current project, you also need to register SVGR Plugin:

rsbuild.config.ts
import { pluginSvgr } from '@rsbuild/plugin-svgr';

export default {
  plugins: [pluginSvgr()],
};

If you are a user of other frameworks, you can refer to Rsbuild Plugin List to select the corresponding framework plugin.

#Config migration

Most configs in Rsbuild and Builder are consistent, with only a few adjustments.

You can refer to the Rsbuild options to view the configs of Rsbuild.

It is worth noting that, compared to Builder, there are some differences in default values and behaviors in Rsbuild:

  • Browserslist: The default is minimum compatible with browsers that support Native ES Modules, refer to Default Browserslist.
  • HTML file output path: default output to the root of the dist directory, refer to Default Directory Structure.
  • Polyfill injection method: Inject on demand by default, refer to output.polyfill.
  • TypeScript type check: not enabled by default, you need to manually register the @rsbuild/plugin-type-check.
  • Modify DevServer configuration: Modify dev and server configuration instead.

#Validating results

After completing the above steps, you have migrated from Modern.js Builder to Rsbuild. You can now try starting the dev server by running the npm run dev command.

If you encounter any issues during the build process, please debug according to the error logs.

#Contents supplement

The current document only covers part of the migration process. If you find suitable content to add, feel free to contribute to the documentation via pull request 🤝.

The documentation for rsbuild can be found in the rsbuild/website directory.