Migrate from webpack
Rspack's configuration is designed based on webpack, enabling you to migrate your project from webpack to Rspack with ease.
This document is primarily aimed at projects using webpack 5. Since Rspack's API and configuration align with webpack 5. For projects not using webpack 5, there are other migration guides that can be referenced:
- For projects using webpack v4 or earlier versions, you can refer to webpack - To v5 from v4 to understand the differences.
- For projects using create-react-app or CRACO, you can refer to Migrating Create React App.
- For projects using Vue CLI, you can refer to Rsbuild - Migrating from Vue CLI.
Checking the Node.js version
Before migrating, make sure that all build environments use a Node.js version supported by Rspack. @rspack/core@2 requires Node.js ^20.19.0 || >=22.12.0.
Keep the Node.js version consistent across local development, CI, and deployment builds. Update version settings such as .nvmrc, Volta configuration, and build images as needed.
Installing Rspack
Install Rspack in your project directory:
Both @rspack/cli and @rspack/dev-server are optional dependencies:
- If you are not using
webpack-cli, no need to install@rspack/cli. - If you are not using
webpack-dev-server, no need to install@rspack/dev-server. - Use the same version of
@rspack/coreand@rspack/cli. The version of@rspack/dev-servermay differ and does not need to match.
Updating package.json
Update your build scripts to use Rspack instead of webpack, see CLI for more details.
Remove unsupported CLI options
Rspack CLI does not support some webpack CLI options, including --progress, --color, --bail, and --output-pathinfo. Keeping these options causes an Unknown option error before the configuration is loaded.
During migration, remove these unsupported options from the build command. If you still need the corresponding behavior, use the Rspack configuration instead:
Updating configuration
Rename the webpack.config.js file to rspack.config.js.
Rspack commands can specify the configuration file with -c or --config, similar to webpack commands.
However, unlike webpack, if a configuration file is not explicitly specified, Rspack defaults to using rspack.config.js.
Rspack supports most webpack configuration options. See Configure Rspack for the complete list of supported options.
Cache configuration
Webpack and Rspack use different cache option shapes. Do not copy webpack cache options directly; map them to the corresponding Rspack cache options.
Disabled cache and memory cache can be kept as-is: cache: false, cache: true, and cache: { type: 'memory' } have the same meaning in Rspack.
For webpack filesystem cache, use Rspack persistent cache, then migrate the supported fields below.
- Change webpack
cache.type: 'filesystem'to Rspackcache.type: 'persistent'.
- Flatten webpack
cache.buildDependenciesinto Rspackcache.buildDependencies, which accepts a file path array.
-
Keep webpack
cache.nameandcache.versionas-is. Rspack uses the samecache.namesemantics to create coexisting caches. -
Move webpack top-level
snapshotoptions into Rspackcache.snapshot.
- Move webpack
cache.cacheDirectoryto Rspackcache.storage.directory, and webpackcache.cacheLocationto Rspackcache.storage.location. The option names differ, but their semantics are aligned. Rspack also defaultsstorage.locationtostorage.directory/cache.name.
The following example shows the same mapping when automating config migration:
Webpack built-in plugins
Rspack has implemented most of webpack's built-in plugins, with the same names and configuration parameters, allowing for easy replacement.
For example, replacing the DefinePlugin:
See Built-in plugins for more information about supported webpack plugins in Rspack.
Community plugins
Rspack supports most of the webpack community plugins and also offers alternative solutions for some currently unsupported plugins.
Check Plugin compat for more information on Rspack's compatibility with popular webpack community plugins.
Some webpack ecosystem packages, such as webpack-node-externals and node-polyfill-webpack-plugin, require newer versions for Rspack compatibility. Before reusing a community package, upgrade it to the latest version, as older versions may rely on incompatible webpack APIs.
unplugin
Some unplugin packages provide separate entry points for each bundler. When a /rspack entry is available, use it instead of /webpack so the plugin selects the Rspack adapter:
copy-webpack-plugin
Use rspack.CopyRspackPlugin instead of copy-webpack-plugin:
mini-css-extract-plugin
Use rspack.CssExtractRspackPlugin instead of mini-css-extract-plugin:
tsconfig-paths-webpack-plugin
Rspack does not support webpack's resolve.plugins option. Use resolve.tsConfig option instead of tsconfig-paths-webpack-plugin:
fork-ts-checker-webpack-plugin
Use ts-checker-rspack-plugin instead of fork-ts-checker-webpack-plugin:
terser-webpack-plugin
For projects that use terser-webpack-plugin to minify JavaScript, we recommend switching to rspack.SwcJsMinimizerRspackPlugin for better build performance:
When you explicitly configure optimization.minimizer, Rspack's default minimizers are disabled, so we recommend keeping both JavaScript and CSS minimizers in the list.
css-minimizer-webpack-plugin
For projects that use css-minimizer-webpack-plugin to minify CSS, we recommend switching to rspack.LightningCssMinimizerRspackPlugin for better build performance:
Loaders
Rspack is compatible with most webpack loaders, so existing loaders can typically be reused without changes.
For optimal performance and consistency, we recommend the following migrations where applicable:
babel-loader
Migrate babel-loader to builtin:swc-loader to use Rspack's built-in SWC transform for better performance.
If you need custom transformation logic using Babel plugins, you can retain babel-loader, but it is recommended to limit its use to fewer files to prevent significant performance degradation.
- Replace @babel/preset-typescript with
builtin:swc-loaderusingdetectSyntax: 'auto':
- Replace @babel/preset-react with SWC's
jsc.transform.reactoption:
swc-loader
When migrating external swc-loader to builtin:swc-loader, only the loader name changes to builtin:swc-loader; all the options remain exactly the same as your original swc-loader config.
file-loader
Migrate file-loader to Asset Modules with asset/resource.
url-loader
Migrate url-loader to Asset Modules with asset/inline.
raw-loader
Migrate raw-loader to Asset Modules with asset/source.
vue-loader
For Vue 3 projects, replace vue-loader with rspack-vue-loader, and update both the plugin import and loader name:
Common webpack package replacements
When migrating webpack ecosystem packages, the following non-plugin packages usually need to be replaced.
For plugin packages, see Plugin compatibility.
Removing webpack dependencies
After successfully building your project with Rspack, check whether any loaders, plugins, or custom build scripts still import webpack or webpack/lib/*.
If imports remain, keep webpack temporarily as a compatibility dependency. Remove webpack-related dependencies after they have been replaced or verified as unnecessary:

