# build-records-webpack-plugin

> A webpack plugin aiming to collect the build stats, including build type, build speed, build time, user information, add so on.

Latest version **0.0.3** (published 2023-07-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install build-records-webpack-plugin
pnpm add build-records-webpack-plugin
yarn add build-records-webpack-plugin
bun add build-records-webpack-plugin
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2023-07-18 |
| First published | 2023-07-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=10.13.0 |
| Dependencies | 2 |
| Unpacked size | 20.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Deland |
| Maintainers | neverland7 |
| Keywords | webpack, plugin, build, stats, speed |

## Links

- npm: https://www.npmjs.com/package/build-records-webpack-plugin
- Repository: https://github.com/Xooone47/build-records-webpack-plugin
- Issues: https://github.com/Xooone47/build-records-webpack-plugin/issues
- npm.io page: https://npm.io/package/build-records-webpack-plugin

## Dependencies (2)

- [user-meta](https://npm.io/package/user-meta.md) ^1.0.0
- [git-branch](https://npm.io/package/git-branch.md) ^2.0.1

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2023-07-18
- 0.0.2 — 2023-07-17
- 0.0.1 — 2023-07-17

## 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:

```json
{
  "buildType": "production",
  "buildSpeed": 362849,
  "finishTime": 1689585090968,
  "finishTimeLocale": "2023/7/17 17:11:30",
  "gitUserName": "Deland",
  "gitUserEmail": "insidethe47s@gmail.com",
  "gitBranch": "master"
}
```

The field **buildType** represents:

- `development-start`: Start a webpack dev-server.
- `development-hmr`: Modify codes and trigger a [Hot Module Replacement](https://webpack.js.org/concepts/hot-module-replacement/) in webpack dev-server.
- `production`: Build bundles with production mode.

## Installation

```bash
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**:

```js
const BuildRecordsWebpackPlugin = require('build-records-webpack-plugin');

module.exports = {
  plugins: [
    new BuildRecordsWebpackPlugin()
  ]
};
```

## Options

```ts
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:

```json
[
  {
    "buildType": "production",
    "buildSpeed": 362849,
    "finishTime": 1689585090968,
    "finishTimeLocale": "2023/7/17 17:11:30",
    "gitUserName": "Deland",
    "gitUserEmail": "insidethe47s@gmail.com",
    "gitBranch": "master"
  },
  {
    "buildType": "production",
    "buildSpeed": 19327,
    "finishTime": 1689586081730,
    "finishTimeLocale": "2023/7/17 17:28:01",
    "gitUserName": "Deland",
    "gitUserEmail": "insidethe47s@gmail.com",
    "gitBranch": "master"
  },
  {
    "buildType": "production",
    "buildSpeed": 18302,
    "finishTime": 1689586126497,
    "finishTimeLocale": "2023/7/17 17:28:46",
    "gitUserName": "Deland",
    "gitUserEmail": "insidethe47s@gmail.com",
    "gitBranch": "master"
  }
]
```

set `outputFormat: 'csv'` to emit buildStats.csv:

```csv
buildType,buildSpeed,finishTime,finishTimeLocale,gitUserName,gitUserEmail,gitBranch
production,508944,1689588410895,2023/7/17 18:06:50,Deland,insidethe47s@gmail.com,master
production,67087,1689588588760,2023/7/17 18:09:48,Deland,insidethe47s@gmail.com,master
```

### options.callback

```js
module.exports = {
  plugins: [
    new BuildRecordsWebpackPlugin({
      callback: (output) => {
        // You can collect stats in your way
        report(output);
      }
    })
  ]
}
```

The type of **Output**:

```ts
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 ( insidethe47s@gmail.com ).

---
_Source: https://npm.io/package/build-records-webpack-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
