diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-05-24 15:10:37 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-05-24 15:11:17 +0200 |
commit | 7a3df06eb573d36142bd1a8e03c5ce8752d300b3 (patch) | |
tree | 70bfaea8884c374876f607774850a3a51c0cb381 /node_modules/webpack/lib/BannerPlugin.js | |
parent | aca1143cb9eed16cf37f04e475e4257418dd18ac (diff) |
fix build issues and add typedoc
Diffstat (limited to 'node_modules/webpack/lib/BannerPlugin.js')
-rw-r--r-- | node_modules/webpack/lib/BannerPlugin.js | 38 |
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();
});
|