-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (30 loc) · 913 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* outputs exactly what went into each chunk
*
* code is taken from the webpack documentation
* https://github.com/webpack/docs/wiki/plugins#after-optimize-chunk-assetschunks-chunk
*/
var util = require("util");
var PrintChunksPlugin = function (options = {}) {
this.options = options;
};
PrintChunksPlugin.prototype.apply = function (compiler) {
var showFull = this.options.showFull;
compiler.plugin("compilation", function (compilation, params) {
compilation.plugin("after-optimize-chunk-assets", function (chunks) {
var items = chunks.map(function (c) {
return {
id: c.id,
name: c.name,
includes: c.modules.map(function (m) {
return m.request;
}),
};
});
console.log(
showFull ? util.inspect(items, { maxArrayLength: null }) : items
);
});
});
};
module.exports = PrintChunksPlugin;