Skip to content

Commit a3d5567

Browse files
committed
Add notification for hidden assets.
1 parent c9cbaf0 commit a3d5567

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

‎lib/Stats.js‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,9 @@ class Stats {
246246
}
247247
if(showAssets) {
248248
const assetsByFile = {};
249+
const compilationAssets = Object.keys(compilation.assets);
249250
obj.assetsByChunkName = {};
250-
obj.assets = Object.keys(compilation.assets).map(asset => {
251+
obj.assets = compilationAssets.map(asset => {
251252
const obj = {
252253
name: asset,
253254
size: compilation.assets[asset].size(),
@@ -263,6 +264,7 @@ class Stats {
263264
assetsByFile[asset] = obj;
264265
return obj;
265266
}).filter(createAssetFilter());
267+
obj.filteredAssets = compilationAssets.length - obj.assets.length;
266268

267269
compilation.chunks.forEach(chunk => {
268270
chunk.files.forEach(asset => {
@@ -589,6 +591,24 @@ class Stats {
589591
color: colors.normal
590592
}]);
591593
});
594+
if(obj.filteredAssets > 0) {
595+
const emtpyCell = {
596+
value: "",
597+
color: colors.normal
598+
};
599+
let filteredAssets = "";
600+
if(obj.assets.length > 0)
601+
filteredAssets += "+ ";
602+
filteredAssets += obj.filteredAssets;
603+
if(obj.assets.length > 0)
604+
filteredAssets += " hidden";
605+
filteredAssets += obj.filteredAssets !== 1 ? " assets" : " asset";
606+
607+
t.push([{
608+
value: filteredAssets,
609+
color: colors.normal
610+
}, emtpyCell, emtpyCell, emtpyCell, emtpyCell, emtpyCell]);
611+
}
592612
table(t, "rrrlll");
593613
}
594614
if(obj.entrypoints) {
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
Hash: 14e131b4e5c91ed5ce4a
22
Time: Xms
3-
Asset Size Chunks Chunk Names
4-
bundle.js 2.92 kB 0 [emitted] main
3+
Asset Size Chunks Chunk Names
4+
bundle.js 2.92 kB 0 [emitted] main
5+
+ 1 hidden asset
56
[0] (webpack)/test/statsCases/exclude-with-loader/index.js 77 bytes {0} [built]
67
[1] (webpack)/test/statsCases/exclude-with-loader/a.txt 43 bytes {0} [built]
78
+ 2 hidden modules

0 commit comments

Comments
 (0)