CssExtractRspackPlugin
Rspack is currently incompatible with mini-css-extract-plugin, but you can use the CssExtractRspackPlugin as a replacement. It can be used with css-loader to extract CSS into separate files.
If your project does not depend on css-loader and mini-css-extract-plugin, it is recommended to use Rspack's built-in CSS solution, which offers better performance.
Example
When using CssExtractRspackPlugin, you need to register the plugin in the plugins section and register CssExtractRspackPlugin.loader in module.rules.
Split extracted CSS with splitChunks
CssExtractRspackPlugin adds extracted CSS modules with the css/mini-extract module type. You can use splitChunks.cacheGroups.{cacheGroup}.type to create a cache group that only matches CSS extracted by CssExtractRspackPlugin, without matching JavaScript modules or native CSS modules.
In this example, extractedCss only selects modules whose module type is css/mini-extract. enforce: true makes the CSS chunk be created even when the normal minSize or request-limit heuristics would skip it; remove enforce if you want the cache group to follow the normal splitChunks heuristics.
Plugin options
Options for CssExtractRspackPlugin.
- Types:
Loader options
Options for CssExtractRspackPlugin.loader.
- Types:
Note
Please note that if you want to use this plugin and css together, it's recommended to explicitly set type to javascript/auto.
For example:

