BannerPlugin

new rspack.BannerPlugin(options);

Adds a banner to the top or bottom of each generated chunk.

Options

  • Type:
type BannerFunction = (args: {
  hash: string;
  chunk: JsChunk;
  filename: string;
}) => string;
type BannerContent = string | BannerFunction;
type BannerPluginOptions = {
  banner: BannerContent;
  entryOnly?: boolean;
  footer?: boolean;
  raw?: boolean;
  stage?: number;
  test?: BannerRules;
  include?: BannerRules;
  exclude?: BannerRules;
};
type BannerPluginArgument = BannerContent | BannerPluginOptions;
  • Default: undefined
NameTypeDefaultDescription
bannerBannerFunction|stringundefinedSpecifies the banner, it will be wrapped in a comment.
entryOnlyboolean|undefinedundefinedIf true, the banner will only be added to the entry chunks.
footerboolean|undefinedundefinedIf true, banner will be placed at the end of the output.
rawboolean|undefinedundefinedIf true, banner will not be wrapped in a comment.
stagenumber|undefinedPROCESS_ASSETS_STAGE_ADDITIONS(-100)The stage of the compilation in which the banner should be injected.
testBannerRules|undefinedundefinedInclude all modules that pass test assertion.
includeBannerRules|undefinedundefinedInclude all modules matching any of these conditions.
excludeBannerRules|undefinedundefinedExclude all modules matching any of these conditions.

Examples

Add a banner to the bottom of each chunk file.

rspack.config.js
module.exports = {
  plugins: [
    new rspack.BannerPlugin({
      banner: 'hello world',
      footer: true,
    }),
  ],
};
ON THIS PAGE