BannerPlugin

new rspack.BannerPlugin(options);

在每個生成的區塊的頂部或底部新增橫幅。

選項

  • 類型
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;
  • 預設值: undefined
名稱類型預設值描述
bannerBannerFunction|stringundefined指定橫幅,它將被包裹在註解中。
entryOnlyboolean|undefinedundefined如果為 true,橫幅將僅新增到入口區塊中。
footerboolean|undefinedundefined如果為 true,橫幅將放置在輸出的末尾。
rawboolean|undefinedundefined如果為 true,橫幅將不會被包裹在註解中。
stagenumber|undefinedPROCESS_ASSETS_STAGE_ADDITIONS(-100)編譯中應注入橫幅的階段。
testBannerRules|undefinedundefined包含所有通過測試斷言的模組。
includeBannerRules|undefinedundefined包含所有符合這些條件的模組。
excludeBannerRules|undefinedundefined排除所有符合這些條件的模組。

範例

在每個區塊檔案的底部新增橫幅。

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