MCPcopy
hub / github.com/webpack/webpack / constructor

Method constructor

lib/BannerPlugin.js:52–76  ·  view source on GitHub ↗

* Normalizes banner options and compiles the configured banner source into a * function that can render per-asset banner text. * @param {BannerPluginArgument} options options object

(options)

Source from the content-addressed store, hash-verified

50 * @param {BannerPluginArgument} options options object
51 */
52 constructor(options) {
53 if (typeof options === "string" || typeof options === "function") {
54 options = {
55 banner: options
56 };
57 }
58
59 /** @type {BannerPluginOptions} */
60 this.options = options;
61
62 const bannerOption = options.banner;
63 if (typeof bannerOption === "function") {
64 const getBanner = bannerOption;
65 /** @type {BannerFunction} */
66 this.banner = this.options.raw
67 ? getBanner
68 : /** @type {BannerFunction} */ (data) => wrapComment(getBanner(data));
69 } else {
70 const banner = this.options.raw
71 ? bannerOption
72 : wrapComment(bannerOption);
73 /** @type {BannerFunction} */
74 this.banner = () => banner;
75 }
76 }
77
78 /**
79 * Validates the configured options and injects rendered banner comments into

Callers

nothing calls this directly

Calls 1

wrapCommentFunction · 0.85

Tested by

no test coverage detected