build-records-webpack-plugin
v0.0.3
Published
A webpack plugin aiming to collect the build stats, including build type, build speed, build time, user information, add so on.
Downloads
2
Maintainers
Readme
build-records-webpack-plugin
A webpack plugin aiming to collect the build records, including build type, build speed, build time, user information, and so on.
A classical output like:
{
"buildType": "production",
"buildSpeed": 362849,
"finishTime": 1689585090968,
"finishTimeLocale": "2023/7/17 17:11:30",
"gitUserName": "Deland",
"gitUserEmail": "[email protected]",
"gitBranch": "master"
}
The field buildType represents:
development-start
: Start a webpack dev-server.development-hmr
: Modify codes and trigger a Hot Module Replacement in webpack dev-server.production
: Build bundles with production mode.
Installation
npm install --save-dev build-records-webpack-plugin
# or
yarn add -D build-records-webpack-plugin
# or
pnpm install -D build-records-webpack-plugin
Usage
webpack.config.js:
const BuildRecordsWebpackPlugin = require('build-records-webpack-plugin');
module.exports = {
plugins: [
new BuildRecordsWebpackPlugin()
]
};
Options
interface PluginOptions {
outputFormat?: 'json' | 'csv' | false; // default: json
outputPath?: string; // default: process.pwd()
callback?: (output: OutputObject) => void;
}
options.outputFormat
set outputFormat: 'json'
to emit buildStats.json:
[
{
"buildType": "production",
"buildSpeed": 362849,
"finishTime": 1689585090968,
"finishTimeLocale": "2023/7/17 17:11:30",
"gitUserName": "Deland",
"gitUserEmail": "[email protected]",
"gitBranch": "master"
},
{
"buildType": "production",
"buildSpeed": 19327,
"finishTime": 1689586081730,
"finishTimeLocale": "2023/7/17 17:28:01",
"gitUserName": "Deland",
"gitUserEmail": "[email protected]",
"gitBranch": "master"
},
{
"buildType": "production",
"buildSpeed": 18302,
"finishTime": 1689586126497,
"finishTimeLocale": "2023/7/17 17:28:46",
"gitUserName": "Deland",
"gitUserEmail": "[email protected]",
"gitBranch": "master"
}
]
set outputFormat: 'csv'
to emit buildStats.csv:
buildType,buildSpeed,finishTime,finishTimeLocale,gitUserName,gitUserEmail,gitBranch
production,508944,1689588410895,2023/7/17 18:06:50,Deland,[email protected],master
production,67087,1689588588760,2023/7/17 18:09:48,Deland,[email protected],master
options.callback
module.exports = {
plugins: [
new BuildRecordsWebpackPlugin({
callback: (output) => {
// You can collect stats in your way
report(output);
}
})
]
}
The type of Output:
enum BuildType {
'development-start' = 'development-start',
'development-hmr' = 'development-hmr',
'production' = 'production',
}
interface OutputObject {
buildType: BuildType;
buildSpeed: number;
finishTime: number;
finishTimeLocale: string;
gitUserName: string;
gitUserEmail: string;
gitBranch: string;
}
Supports
webpack 4, webpack 5
Maintainer
Deland ( [email protected] ).