Skip to content

Commit e60514a

Browse files
committed
add compile time to statistics
1 parent e033f1e commit e60514a

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ else `stats` as json:
468468
``` javascript
469469
{
470470
hash: "52bd9213...38d",
471+
time: 1234, // in ms
471472
chunkCount: 2,
472473
modulesCount: 10,
473474
modulesIncludingDuplicates: 10,

‎lib/formatOutput.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = function(stats, options) {
88
}
99

1010
buf.push("Hash: "+c("\033[1m") + stats.hash + c("\033[22m"));
11+
buf.push("Compile Time: "+c("\033[1m") + Math.round(stats.time) + "ms" + c("\033[22m"));
1112
buf.push("Chunks: "+c("\033[1m") + stats.chunkCount + c("\033[22m"));
1213
buf.push("Modules: "+c("\033[1m") + stats.modulesCount + c("\033[22m"));
1314
buf.push("Modules including duplicates: "+c("\033[1m") + stats.modulesIncludingDuplicates + c("\033[22m"));

‎lib/webpack.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ module.exports = function(context, moduleName, options, callback) {
154154
return webpack(context, moduleName, options, callback);
155155
}
156156
function webpack(context, moduleName, options, callback) {
157+
var startTime = new Date();
157158

158159
// Defaults
159160
if(!options.outputJsonpFunction)
@@ -197,12 +198,15 @@ function webpack(context, moduleName, options, callback) {
197198

198199
options.loader = options.loader || {};
199200
options.loader.emitFile = options.loader.emitFile || function(filename, content) {
200-
fileWrites.push([path.join(options.outputDirectory, filename), content]);
201+
options.internal.fileWrites.push([path.join(options.outputDirectory, filename), content]);
201202
}
202203

204+
options.internal = {};
205+
203206
// all writes to files
204207
// items: [filename, content]
205208
var fileWrites = [];
209+
options.internal.fileWrites = fileWrites;
206210

207211
// Some status info
208212
options.events.emit("task", "create ouput directory");
@@ -425,6 +429,7 @@ function webpack(context, moduleName, options, callback) {
425429
buffer.warnings = depTree.warnings;
426430
buffer.errors = depTree.errors;
427431
buffer.fileModules = fileModulesMap;
432+
buffer.time = new Date() - startTime;
428433
options.events.emit("task-end", "statistics");
429434
options.events.emit("bundle", buffer);
430435
callback(null, buffer);

0 commit comments

Comments
 (0)