Compatibility
Rspack’s API and configuration align with webpack 5, and it supports most webpack configuration options, most built-in plugins (same names and parameters) and most loaders. The guide is written for webpack 5 projects: on webpack 4 or earlier, read webpack’s own v4 to v5 guide for the differences, and Create React App or Vue CLI projects have their own guides.
Before you switch
- Check Node.js on every build machine, CI included.
@rspack/core@2requires Node.js^20.19.0 || >=22.12.0. - Install
@rspack/core, plus@rspack/cliand@rspack/dev-serverif you usedwebpack-cliandwebpack-dev-server. Keep@rspack/coreand@rspack/clion the same version. - Point your scripts at
rspack dev,rspack buildandrspack preview, and renamewebpack.config.jstorspack.config.js, the file Rspack loads when none is given. - Take built-in plugins from
@rspack/coreinstead ofwebpack(new webpack.DefinePluginbecomesnew rspack.DefinePlugin), and replace ecosystem packages:webpack-dev-middlewarebecomes@rspack/dev-middleware,webpack-chainbecomesrspack-chain,webpack-mergebecomesrspack-merge. - Once the build works, remove
webpack,webpack-cliandwebpack-dev-server, unless a loader, plugin or script still importswebpackorwebpack/lib/*.
Pitfalls
- Cache options have a different shape and cannot be copied.
cache.type: 'filesystem'becomes'persistent',buildDependenciesbecomes a flat array of paths, top-levelsnapshotmoves undercache.snapshot, andcacheDirectoryandcacheLocationbecomecache.storage.directoryandcache.storage.location. cache: falsedoes not turn off the separateincrementaloption. Setincremental: falseas well if you want no reuse between compilations.- The CLI rejects
--progress,--color,--bailand--output-pathinfowith anUnknown optionerror. Move that behaviour into the config. resolve.pluginsis not supported, sotsconfig-paths-webpack-plugingives way toresolve.tsConfig.- Several community plugins have Rspack counterparts:
html-rspack-plugin,ts-checker-rspack-plugin,rspack.CopyRspackPlugin,rspack.CssExtractRspackPlugin. Some packages, such aswebpack-node-externals, need their latest version to work with Rspack. - Setting
optimization.minimizeryourself disables the default minimizers, so list both a JavaScript and a CSS minimizer. - Vue 3 projects replace
vue-loaderwithrspack-vue-loader.