Skip to content

Commit 30c4174

Browse files
committed
fixes stats as json
1 parent c88bce3 commit 30c4174

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

bin/webpack.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ function ifArg(name, fn, init) {
5353

5454

5555
var outputOptions = {
56-
modules: true,
57-
chunks: false,
5856
cached: false,
5957
context: options.context
6058
};
@@ -79,14 +77,21 @@ ifArg("sort-assets-by", function(value) {
7977
outputOptions.assetsSort = value;
8078
});
8179

82-
ifArg("display-chunks", function(bool) {
83-
outputOptions.modules = !bool;
84-
outputOptions.chunks = bool;
85-
});
86-
87-
ifArg("display-reasons", function(bool) {
88-
outputOptions.reasons = bool;
89-
});
80+
if(!outputOptions.json) {
81+
ifArg("display-chunks", function(bool) {
82+
outputOptions.modules = !bool ;
83+
outputOptions.chunks = bool;
84+
});
85+
86+
ifArg("display-reasons", function(bool) {
87+
outputOptions.reasons = bool;
88+
});
89+
} else {
90+
outputOptions.chunks = true;
91+
outputOptions.modules = true;
92+
outputOptions.chunkModules = true;
93+
outputOptions.reasons = true;
94+
}
9095

9196
var webpack = require("../lib/webpack.js");
9297

lib/Stats.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Stats.prototype.toJson = function toJson(options, forToString) {
3131
var showCachedModules = d(options.cached, true);
3232
var showReasons = d(options.reasons, !forToString);
3333
var showChildren = d(options.children, true);
34+
var showSource = d(options.source, !forToString);
3435
var sortModules = d(options.modulesSort, "id");
3536
var sortChunks = d(options.chunksSort, "id");
3637
var sortAssets = d(options.assetsSort, "");
@@ -129,6 +130,9 @@ Stats.prototype.toJson = function toJson(options, forToString) {
129130
return obj;
130131
});
131132
}
133+
if(showSource && module._source) {
134+
obj.source = module._source.source();
135+
}
132136
return obj;
133137
}
134138
if(showChunks) {

0 commit comments

Comments
 (0)