Bundler chain is a subset of webpack chain, which contains part of the webpack chain API that you can use to modify both webpack and Rspack configuration.
modifyBundlerChain is used to call the bundler chain to modify the Rspack configuration.
This hook only supports modifying the configuration of the non-differentiated parts of webpack and Rspack. For example, modifying the devtool configuration option (webpack and Rspack have the same devtool property value type), or adding an Rspack-compatible webpack plugin.
onBeforeCreateCompiler is a callback function that is triggered after the Compiler instance has been created, but before the build process begins. This hook is called when you run rsbuild.startDevServer, rsbuild.build, or rsbuild.createCompiler.
You can access the Compiler instance object through the compiler parameter:
If the current bundler is webpack, you will get the webpack Compiler object.
If the current bundler is Rspack, you will get the Rspack Compiler object.
onAfterCreateCompiler is a callback function that is triggered after the compiler instance has been created, but before the build process. This hook is called when you run rsbuild.startDevServer, rsbuild.build, or rsbuild.createCompiler.
You can access the Compiler instance object through the compiler parameter:
If the current bundler is webpack, you will get the webpack Compiler object.
If the current bundler is Rspack, you will get the Rspack Compiler object.
onBeforeBuild is a callback function that is triggered before the production build is executed. You can access the final configuration array of the underlying bundler through the `bundlerConfigs' parameter:
If the current bundler is webpack, you will get a webpack configuration array.
If the current bundler is Rspack, you will get an Rspack configuration array.
The configuration array can contain one or more configurations, depending on the current target config of Rsbuild.
onAfterBuild is a callback function that is triggered after running the production build. You can access the build result information via the `stats' parameter:
If the current bundler is webpack, you will get webpack Stats.
If the current bundler is Rspack, you will get Rspack Stats.