Skip to content

Commit 5266a30

Browse files
author
Connor Clark
committed
add builtAt stats option. use locale string functions
1 parent 152575c commit 5266a30

12 files changed

Lines changed: 22 additions & 4 deletions

File tree

lib/Stats.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class Stats {
105105
const showEnv = optionOrLocalFallback(options.env, false);
106106
const showVersion = optionOrLocalFallback(options.version, true);
107107
const showTimings = optionOrLocalFallback(options.timings, true);
108+
const showBuiltAt = optionOrLocalFallback(options.builtAt, true);
108109
const showAssets = optionOrLocalFallback(options.assets, true);
109110
const showEntrypoints = optionOrLocalFallback(options.entrypoints, true);
110111
const showChunks = optionOrLocalFallback(options.chunks, !forToString);
@@ -252,6 +253,9 @@ class Stats {
252253
if(showHash) obj.hash = this.hash;
253254
if(showTimings && this.startTime && this.endTime) {
254255
obj.time = this.endTime - this.startTime;
256+
}
257+
258+
if(showBuiltAt && this.endTime) {
255259
obj.builtAt = this.endTime;
256260
}
257261

@@ -618,11 +622,11 @@ class Stats {
618622
newline();
619623
}
620624
if(typeof obj.builtAt === "number") {
621-
const now = (new Date(obj.builtAt)).toString().split(" ");
625+
const builtAtDate = new Date(obj.builtAt);
622626
colors.normal("Built at: ");
623-
colors.normal(`${now[0]} ${now[1]} ${now[2]} ${now[3]} `);
624-
colors.bold(now[4]);
625-
colors.normal(now[6] ? ` ${now[5]} ${now[6]}` : ` ${now[5]}`);
627+
colors.normal(builtAtDate.toLocaleDateString());
628+
colors.normal(" ");
629+
colors.bold(builtAtDate.toLocaleTimeString());
626630
newline();
627631
}
628632
if(obj.env) {

schemas/WebpackOptions.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,10 @@
16551655
"type": "boolean",
16561656
"description": "add timing information"
16571657
},
1658+
"builtAt": {
1659+
"type": "boolean",
1660+
"description": "add built at time information"
1661+
},
16581662
"performance": {
16591663
"type": "boolean",
16601664
"description": "add performance hint flags"

test/statsCases/async-commons-chunk-auto/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const path = require("path");
22
const stats = {
33
hash: false,
44
timings: false,
5+
builtAt: false,
56
assets: false,
67
chunks: true,
78
chunkOrigins: true,

test/statsCases/async-commons-chunk/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = {
99
stats: {
1010
hash: false,
1111
timings: false,
12+
builtAt: false,
1213
assets: false,
1314
chunks: true,
1415
chunkOrigins: true,

test/statsCases/circular-correctness/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = {
77
stats: {
88
hash: false,
99
timings: false,
10+
builtAt: false,
1011
assets: false,
1112
chunks: true,
1213
chunkModules: true,

test/statsCases/graph-correctness-entries/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = {
1010
stats: {
1111
hash: false,
1212
timings: false,
13+
builtAt: false,
1314
assets: false,
1415
chunks: true,
1516
chunkModules: true,

test/statsCases/graph-correctness-modules/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = {
1010
stats: {
1111
hash: false,
1212
timings: false,
13+
builtAt: false,
1314
assets: false,
1415
chunks: true,
1516
chunkModules: true,

test/statsCases/module-deduplication-named/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = {
1111
stats: {
1212
hash: false,
1313
timings: false,
14+
builtAt: false,
1415
chunks: true,
1516
chunkModules: true,
1617
modules: false

test/statsCases/module-deduplication/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = {
1111
stats: {
1212
hash: false,
1313
timings: false,
14+
builtAt: false,
1415
chunks: true,
1516
chunkModules: true,
1617
modules: false

test/statsCases/parse-error/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = {
55
entry: "./index",
66
stats: {
77
timings: false,
8+
builtAt: false,
89
hash: false,
910
modules: true,
1011
chunks: false

0 commit comments

Comments
 (0)