BannerPlugin

يضيف banner في أعلى كل chunk يتم توليده.

import webpack from "webpack";

new webpack.BannerPlugin(banner);
// أو
new webpack.BannerPlugin(options);

الخيارات

{
  banner: string | function, // نص banner أو دالة، وسيتم وضعه داخل تعليق
  raw: boolean, // إذا كانت true، فلن يضع webpack banner داخل تعليق
  entryOnly: boolean, // إذا كانت true، فسيضاف banner إلى entry chunks فقط
  test: string | RegExp | [string, RegExp], // يشمل كل modules التي تطابق الشرط
  include: string | RegExp | [string, RegExp], // يشمل modules المطابقة لهذه الشروط
  exclude: string | RegExp | [string, RegExp], // يستبعد modules المطابقة لهذه الشروط
  footer?: boolean, // إذا كانت true، يوضع banner في نهاية bundle
  stage?: number, // المرحلة التي يضاف فيها banner أثناء compilation
}

الاستخدام

import webpack from "webpack";

// نص
new webpack.BannerPlugin({
  banner: "hello world",
});

// دالة
new webpack.BannerPlugin({
  banner: (yourVariable) => `yourVariable: ${yourVariable}`,
});

// إضافة رسالة banner بعد التصغير وأي تعديل على asset
new webpack.BannerPlugin({
  raw: true,
  banner: "/* banner كنص خام */",
  stage: webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT,
});

placeholders

منذ webpack 2.5.0، يتم تقييم placeholders داخل نص banner.

import webpack from "webpack";

new webpack.BannerPlugin({
  banner:
    "fullhash:[fullhash], chunkhash:[chunkhash], name:[name], filebase:[filebase], query:[query], file:[file]",
});
·تعديل هذه الصفحة
السابق ›
AutomaticPrefetchPlugin
‹ التالي
ContextExclusionPlugin

2 مساهمون

MohaDev-69RlxChap2