Plugins

The plugins option is used to customize the Rspack build process in a variety of ways. Rspack comes with a variety built-in plugins available under rspack.[plugin-name]. See Plugins page for a list of plugins and documentation but note that there are a lot more out in the community.

  • Type: Array<RspackPluginInstance | RspackPluginFunction | RspackBuiltinPlugin>
  • Default: []

An array of webpack plugins. For example, DefinePlugin allows you to create global constants which can be configured at compile time. This can be useful for allowing different behavior between development builds and release builds.

rspack.config.js
module.exports = {
  //...
  plugins: [
    new rspack.DefinePlugin({
      // Definitions...
    }),
  ],
};

Rspack strives to maintain compatibility with the webpack plugin ecosystem to leverage the excellent features that have been accumulated and validated by the community. Please refer to the Plugin Compatibility List to access a list of webpack plugins that have passed our compatibility tests:

rspack.config.js
const rspack = require('@rspack/core');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  //...
  plugins: [new HtmlWebpackPlugin()],
};