BannerPlugin

new rspack.BannerPlugin(options);

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

  • options

    • Type:
    type BannerContent = string;
    type BannerRules = string | RegExp | Array<string | RegExp>;
    type BannerPluginOptions = {
      banner: BannerContent;
      entryOnly?: boolean;
      footer?: boolean;
      raw?: boolean;
      test?: BannerRules;
      include?: BannerRules;
      exclude?: BannerRules;
    };
    export type BannerPluginArgument = BannerContent | BannerPluginOptions;
    • Default: undefined
    NameTypeDefaultDescription
    bannerstringundefinedSpecifies 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.
    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.

Add a banner to the top or bottom of each chunk file.

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