forked from FormidableLabs/webpack-stats-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
52 lines (51 loc) · 1.41 KB
/
webpack.config.js
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
44
45
46
47
48
49
50
51
52
/**
* Webpack configuration
*/
var path = require("path");
var StatsWriterPlugin = require("../index").StatsWriterPlugin;
module.exports = {
cache: true,
context: __dirname,
entry: "./main.js",
output: {
path: path.join(__dirname, "build"),
filename: "[hash].main.js"
},
plugins: [
// Try various defaults and options.
new StatsWriterPlugin(),
new StatsWriterPlugin({}),
new StatsWriterPlugin({
filename: "stats-transform.json",
fields: null,
transform: function (data) {
return JSON.stringify(data.assetsByChunkName, null, 2);
}
}),
new StatsWriterPlugin({
filename: "stats-transform.md",
fields: null,
transform: function (data) {
var assetsByChunkName = data.assetsByChunkName;
return Object.keys(assetsByChunkName).reduce(function (acc, key) {
return acc += key + " | " + assetsByChunkName[key] + "\n";
}, "Name | Asset\n:--- | :----\n");
}
}),
new StatsWriterPlugin({
filename: "stats-transform-custom-obj.json",
transform: function (data) {
return JSON.stringify({
main: data.assetsByChunkName.main[0]
}, null, 2);
}
}),
new StatsWriterPlugin({
filename: "stats-custom.json"
}),
// Relative paths work, but absolute paths do not currently.
new StatsWriterPlugin({
filename: "../build2/stats-custom2.json"
})
]
};