Plugins

Customize the build process.

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

RspackPluginInstance

interface RspackPluginInstance {
  apply: (compiler: Compiler) => void;
}

Among them, the interface provided on Compiler can refer to Plugin API.

usage:

rspack.config.js
class CustomPlugin {
  apply(compiler) {
    // some operations
  }
}

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

RspackPluginFunction

type RspackPluginFunction = (this: Compiler, compiler: Compiler) => void;

usage:

rspack.config.js
function customPlugin(compiler) {
  // some operations
}

module.exports = {
  plugins: [customPlugin],
};