From 7a3df06eb573d36142bd1a8e03c5ce8752d300b3 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 24 May 2017 15:10:37 +0200 Subject: fix build issues and add typedoc --- node_modules/webpack/lib/BannerPlugin.js | 38 +++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'node_modules/webpack/lib/BannerPlugin.js') 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(); }); -- cgit v1.2.3