mirror of https://github.com/webpack/webpack.git
added `exclude` option to stats
added `--display-exclude` and `--display-modules` exclude common package manager folders by default fixes #473
This commit is contained in:
parent
1a10838a61
commit
992231a1c8
|
@ -34,6 +34,10 @@ optimist
|
|||
|
||||
.boolean("hide-modules").describe("hide-modules")
|
||||
|
||||
.string("display-exclude").describe("display-exclude")
|
||||
|
||||
.boolean("display-modules").describe("display-modules")
|
||||
|
||||
.boolean("display-chunks").describe("display-chunks")
|
||||
|
||||
.boolean("display-error-details").describe("display-error-details")
|
||||
|
@ -89,6 +93,10 @@ ifArg("sort-assets-by", function(value) {
|
|||
outputOptions.assetsSort = value;
|
||||
});
|
||||
|
||||
ifArg("display-exclude", function(value) {
|
||||
outputOptions.exclude = value;
|
||||
});
|
||||
|
||||
if(!outputOptions.json) {
|
||||
ifArg("display-chunks", function(bool) {
|
||||
outputOptions.modules = !bool;
|
||||
|
@ -116,6 +124,9 @@ if(!outputOptions.json) {
|
|||
if(bool)
|
||||
outputOptions.cachedAssets = true;
|
||||
});
|
||||
|
||||
if(!outputOptions.exclude && !argv["display-modules"])
|
||||
outputOptions.exclude = ["node_modules", "bower_components", "jam", "components"];
|
||||
} else {
|
||||
outputOptions.chunks = true;
|
||||
outputOptions.modules = true;
|
||||
|
|
40
lib/Stats.js
40
lib/Stats.js
|
@ -37,9 +37,25 @@ Stats.prototype.toJson = function toJson(options, forToString) {
|
|||
var showChildren = d(options.children, true);
|
||||
var showSource = d(options.source, !forToString);
|
||||
var showErrorDetails = d(options.errorDetails, !forToString);
|
||||
var excludeModules = [].concat(d(options.exclude, [])).map(function(str) {
|
||||
if(typeof str !== "string") return str;
|
||||
return new RegExp("[\\\\/]" + str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") + "([\\\\/]|$|!|\\?)");
|
||||
});
|
||||
var sortModules = d(options.modulesSort, "id");
|
||||
var sortChunks = d(options.chunksSort, "id");
|
||||
var sortAssets = d(options.assetsSort, "");
|
||||
|
||||
function moduleFilter(module) {
|
||||
if(!showCachedModules && !module.built) {
|
||||
return false;
|
||||
}
|
||||
if(excludeModules.length === 0)
|
||||
return true;
|
||||
var ident = module.identifier();
|
||||
return !excludeModules.some(function(regExp) {
|
||||
return regExp.test(ident);
|
||||
});
|
||||
}
|
||||
|
||||
function sortByField(field) {
|
||||
if(!field) return function() { return 0; }
|
||||
|
@ -184,12 +200,8 @@ Stats.prototype.toJson = function toJson(options, forToString) {
|
|||
})
|
||||
};
|
||||
if(showChunkModules) {
|
||||
obj.modules = chunk.modules.map(fnModule);
|
||||
if(!showCachedModules) {
|
||||
obj.modules = obj.modules.filter(function(m) {
|
||||
return m.built;
|
||||
});
|
||||
}
|
||||
obj.modules = chunk.modules.filter(moduleFilter).map(fnModule);
|
||||
obj.filteredModules = chunk.modules.length - obj.modules.length;
|
||||
obj.modules.sort(sortByField(sortModules));
|
||||
}
|
||||
if(showChunkOrigins) {
|
||||
|
@ -211,12 +223,8 @@ Stats.prototype.toJson = function toJson(options, forToString) {
|
|||
obj.chunks.sort(sortByField(sortChunks));
|
||||
}
|
||||
if(showModules) {
|
||||
obj.modules = compilation.modules.map(fnModule);
|
||||
if(!showCachedModules) {
|
||||
obj.modules = obj.modules.filter(function(m) {
|
||||
return m.built;
|
||||
});
|
||||
}
|
||||
obj.modules = compilation.modules.filter(moduleFilter).map(fnModule);
|
||||
obj.filteredModules = compilation.modules.length - obj.modules.length;
|
||||
obj.modules.sort(sortByField(sortModules));
|
||||
}
|
||||
if(showChildren) {
|
||||
|
@ -523,6 +531,10 @@ Stats.jsonToString = function jsonToString(obj, useColors) {
|
|||
}
|
||||
processProfile(module);
|
||||
});
|
||||
if(chunk.filteredModules > 0) {
|
||||
normal(" + " + chunk.filteredModules + " hidden modules");
|
||||
newline();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -557,6 +569,10 @@ Stats.jsonToString = function jsonToString(obj, useColors) {
|
|||
}
|
||||
processProfile(module);
|
||||
});
|
||||
if(obj.filteredModules > 0) {
|
||||
normal(" + " + obj.filteredModules + " hidden modules");
|
||||
newline();
|
||||
}
|
||||
}
|
||||
if(obj.warnings) {
|
||||
obj.warnings.forEach(function(warning) {
|
||||
|
|
Loading…
Reference in New Issue