This section introduces how to migrate a project using webpack to Rsbuild.
First, you need to replace the npm dependencies of webpack with Rsbuild's dependencies.
Next, you need to update the npm scripts in your package.json to use Rsbuild's CLI commands.
Create a Rsbuild configuration file rsbuild.config.ts
in the same directory as package.json, and add the following content:
In a webpack project, there might be some complex webpack.config.js
configuration files.
After migrating to Rsbuild, most webpack configurations are built-in and do not require manual configuration, such as output, resolve, module.rules, etc.
For the few webpack configurations that need to be migrated, you can choose the following options:
webpack uses the entry
field to set the build entry. In Rsbuild, you can use source.entry to set it.
Since Rsbuild has built-in some common loaders and plugins, you can remove the following dependencies, which will significantly improve the dependency installation speed of the project:
The above only lists some of the common dependencies that can be removed. In actual webpack projects, there may be many other dependencies, please handle them as appropriate.
Rsbuild does not support the use of Rspack's devServer config. Please refer to Rspack Dev Server for replacement.
After completing the above steps, you have completed the basic migration from webpack to Rsbuild. You can now run the npm run dev
command to try starting the dev server.
If you encounter any issues during the build process, please debug according to the error log, or check the webpack configuration to see if there are any necessary configurations that have not been migrated to Rsbuild.
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.