-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathprocessStats.js
More file actions
43 lines (39 loc) · 1.17 KB
/
processStats.js
File metadata and controls
43 lines (39 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const webpack = require('webpack');
const fs = require('fs');
const config = require('./webpack.config');
webpack(config, (err, stats) => {
const jsonStats = stats.toJson({
assets: false,
cached: false,
cachedAssets: false,
children: false,
chunks: true,
chunkModules: false,
chunkOrigins: false,
depth: false,
entrypoints: false,
errors: true,
errorDetails: true,
// Doesn't work
// Waiting for https://github.com/webpack/webpack/issues/4141
exclude: [/node_modules/],
hash: false,
modules: true,
performance: false,
providedExports: false,
publicPath: false,
reasons: false,
source: false,
timings: false,
usedExports: false,
version: false,
warnings: false
});
const modules = jsonStats.modules
// Waiting for https://github.com/webpack/webpack/issues/4141
.filter(({identifier}) => !/node_modules/.test(identifier.split('!').pop()))
.map(({chunks, identifier}) => ({identifier: identifier.split('!').pop(), chunks}));
const chunks = jsonStats.chunks
.map(({id, files}) => ({id, files}));
fs.writeFileSync('./stats.json', JSON.stringify({modules, chunks}))
});