aboutsummaryrefslogtreecommitdiff
path: root/node_modules/webpack/lib/BannerPlugin.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/webpack/lib/BannerPlugin.js')
-rw-r--r--node_modules/webpack/lib/BannerPlugin.js38
1 files changed, 30 insertions, 8 deletions
diff --git a/node_modules/webpack/lib/BannerPlugin.js b/node_modules/webpack/lib/BannerPlugin.js
index c37a0d3ca..342a30328 100644
--- a/node_modules/webpack/lib/BannerPlugin.js
+++ b/node_modules/webpack/lib/BannerPlugin.js
@@ -8,10 +8,10 @@
const ConcatSource = require("webpack-sources").ConcatSource;
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
-function wrapComment(str) {
+const wrapComment = (str) => {
if(!str.includes("\n")) return `/*! ${str} */`;
return `/*!\n * ${str.split("\n").join("\n * ")}\n */`;
-}
+};
class BannerPlugin {
constructor(options) {
@@ -33,14 +33,36 @@ class BannerPlugin {
compilation.plugin("optimize-chunk-assets", (chunks, callback) => {
chunks.forEach((chunk) => {
if(options.entryOnly && !chunk.isInitial()) return;
-
chunk.files
.filter(ModuleFilenameHelpers.matchObject.bind(undefined, options))
- .forEach((file) =>
- compilation.assets[file] = new ConcatSource(
- banner, "\n", compilation.assets[file]
- )
- );
+ .forEach((file) => {
+ let basename;
+ let query = "";
+ let filename = file;
+ const hash = compilation.hash;
+ const querySplit = filename.indexOf("?");
+
+ if(querySplit >= 0) {
+ query = filename.substr(querySplit);
+ filename = filename.substr(0, querySplit);
+ }
+
+ if(filename.indexOf("/") < 0) {
+ basename = filename;
+ } else {
+ basename = filename.substr(filename.lastIndexOf("/") + 1);
+ }
+
+ const comment = compilation.getPath(banner, {
+ hash,
+ chunk,
+ filename,
+ basename,
+ query,
+ });
+
+ return compilation.assets[file] = new ConcatSource(comment, "\n", compilation.assets[file]);
+ });
});
callback();
});