Skip to content

Commit 147740a

Browse files
committed
add -o option to specify stats.json file name
1 parent f832ca4 commit 147740a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
var fs = require('fs')
12
var path = require('path')
23
var crypto = require('crypto')
34
var through = require('through2')
45

5-
module.exports = function webpackStats (b) {
6+
module.exports = function webpackStats (b, opts) {
67
var stats = null
78
var startTime
89
var chunkId
@@ -21,6 +22,8 @@ module.exports = function webpackStats (b) {
2122
chunkId = 0
2223
}
2324

25+
var statsFileName = opts.o || 'stats.json'
26+
2427
var mainBundleName = 'bundle.js'
2528
if (b.argv) mainBundleName = b.argv.o || b.argv.outfile || mainBundleName
2629

@@ -34,7 +37,7 @@ module.exports = function webpackStats (b) {
3437

3538
addChunk(mainBundleName, b.pipeline)
3639
b.pipeline.get('wrap').on('end', function () {
37-
require('fs').writeFile('stats.json', JSON.stringify(stats, null, 2), function () {})
40+
fs.writeFile(statsFileName, JSON.stringify(stats, null, 2), function () {})
3841
})
3942
}
4043
function addChunk (name, pipeline) {

0 commit comments

Comments
 (0)