Skip to content

Commit 81235e1

Browse files
committed
Add stats.moduleAssets to show assets inside modules in the Stats
1 parent c03293a commit 81235e1

File tree

8 files changed

+37
-19
lines changed

8 files changed

+37
-19
lines changed

lib/Stats.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ class Stats {
136136
options.nestedModules,
137137
true
138138
);
139+
const showModuleAssets = optionOrLocalFallback(
140+
options.moduleAssets,
141+
!forToString
142+
);
139143
const showDepth = optionOrLocalFallback(options.depth, !forToString);
140144
const showCachedModules = optionOrLocalFallback(options.cached, true);
141145
const showCachedAssets = optionOrLocalFallback(options.cachedAssets, true);
@@ -417,7 +421,6 @@ class Stats {
417421
optional: module.optional,
418422
prefetched: module.prefetched,
419423
chunks: Array.from(module.chunksIterable, chunk => chunk.id),
420-
assets: Object.keys(module.buildInfo.assets || {}),
421424
issuer: module.issuer && module.issuer.identifier(),
422425
issuerId: module.issuer && module.issuer.id,
423426
issuerName:
@@ -435,6 +438,9 @@ class Stats {
435438
errors: module.errors ? module.errors.length : 0,
436439
warnings: module.warnings ? module.warnings.length : 0
437440
};
441+
if (showModuleAssets) {
442+
obj.assets = Object.keys(module.buildInfo.assets || {});
443+
}
438444
if (showReasons) {
439445
obj.reasons = module.reasons
440446
.map(reason => {
@@ -867,6 +873,9 @@ class Stats {
867873
if (module.built) {
868874
colors.green(" [built]");
869875
}
876+
if (module.assets && module.assets.length) {
877+
colors.magenta(` [${module.assets.length} asset]`);
878+
}
870879
if (module.prefetched) {
871880
colors.magenta(" [prefetched]");
872881
}

schemas/WebpackOptions.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,6 +1757,10 @@
17571757
"type": "boolean",
17581758
"description": "add information about modules nested in other modules (like with module concatenation)"
17591759
},
1760+
"moduleAssets": {
1761+
"type": "boolean",
1762+
"description": "add information about assets inside modules"
1763+
},
17601764
"children": {
17611765
"type": "boolean",
17621766
"description": "add children information"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Hash: d71bd16b0b20f34e994a
2+
Time: Xms
3+
Built at: Thu Jan 01 1970 00:00:00 GMT
4+
Entrypoint main = main.js
5+
chunk {0} 0.js 68 bytes <{1}> [rendered]
6+
[0] ./node_modules/a/1.png 51 bytes {0} [built] [1 asset]
7+
[1] ./node_modules/a/index.js 17 bytes {0} [built]
8+
chunk {1} main.js (main) 12 bytes >{0}< [entry] [rendered]
9+
[2] ./index.js 12 bytes {1} [built]
10+
[0] ./node_modules/a/1.png 51 bytes {0} [built] [1 asset]
11+
[1] ./node_modules/a/index.js 17 bytes {0} [built]
12+
[2] ./index.js 12 bytes {1} [built]

test/statsCases/modules-assets/webpack.config.js renamed to test/statsCases/module-assets/webpack.config.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,24 @@ module.exports = {
22
mode: "production",
33
entry: "./index",
44
stats: {
5+
assets: false,
56
chunks: true,
67
chunkModules: true,
7-
modules: true
8+
modules: true,
9+
moduleAssets: true
810
},
911
module: {
1012
rules: [
1113
{
1214
test: /\.png$/,
13-
use: ["file-loader"]
15+
use: [
16+
{
17+
loader: "file-loader",
18+
options: {
19+
name: "[name].[ext]"
20+
}
21+
}
22+
]
1423
}
1524
]
1625
}

test/statsCases/modules-assets/expected.txt

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)