# version-file-webpack-plugin

> Generate version infomation file in webpack output folder

Latest version **0.2.3** (published 2022-01-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install version-file-webpack-plugin
pnpm add version-file-webpack-plugin
yarn add version-file-webpack-plugin
bun add version-file-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.2.3 |
| Published | 2022-01-12 |
| First published | 2021-04-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | wangcch |
| Maintainers | wangcch |
| Keywords | webpack, plugin, version |

## Links

- npm: https://www.npmjs.com/package/version-file-webpack-plugin
- Repository: https://github.com/wangcch/version-file-webpack-plugin
- Homepage: https://github.com/wangcch/version-file-webpack-plugin#readme
- Issues: https://github.com/wangcch/version-file-webpack-plugin/issues
- npm.io page: https://npm.io/package/version-file-webpack-plugin

## Recent versions

- 0.2.3 (latest) — 2022-01-12
- 0.2.3-alpha.0 — 2021-08-09
- 0.2.2 — 2021-05-12
- 0.2.1 — 2021-05-12
- 0.2.0 — 2021-05-12
- 0.1.0 — 2021-04-27

## README

# version-file-webpack-plugin

Generate version infomation file in webpack output folder

[![test](https://github.com/wangcch/version-file-webpack-plugin/actions/workflows/main.yml/badge.svg)](https://github.com/wangcch/version-file-webpack-plugin/actions/workflows/main.yml)
[![npm](https://img.shields.io/npm/v/version-file-webpack-plugin.svg)](https://www.npmjs.com/package/version-file-webpack-plugin)
[![](https://img.shields.io/github/license/wangcch/version-file-webpack-plugin)](https://github.com/wangcch/version-file-webpack-plugin/blob/main/LICENSE)

## usage

```shell
npm i -D version-file-webpack-plugin

# or

yarn add -D version-file-webpack-plugin
```

```shell
# install dependencies
yarn

# build for production with minification
yarn build

# test
yarn test
```

## options

| options                | type           | default                            | description                                                                                                                |
| ---------------------- | -------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| output                 | string         | \_\_version.json                   | file path                                                                                                                  |
| absolute               | boolean        | false                              | Absolute path of output                                                                                                    |
| data                   | object         | `{}`                               | output data                                                                                                                |
| jsonStringify.replacer | array          | null                               | JSON.stringify [replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) |
| jsonStringify.space    | string\|number | 2                                  | JSON.stringify [space](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)    |
| writeFileOptions       | object         | `{ encoding: "utf-8", flag: "w" }` | fs.writeFile options                                                                                                       |

## config

```js
// webpack.config.js

const VersionPlugin = require('version-file-webpack-plugin');

module.exports = {
  // ...
  plugins: [
    new VersionPlugin({
      output: '__info/version.txt', // @default `__version.json`
      data: process.env,
    });
  ],
};
```

### nextjs

[custom webpack config](https://nextjs.org/docs/api-reference/next.config.js/custom-webpack-config)

```js
// next.config.js

module.exports = {
  webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
    config.plugins.push(
      new versionFile({
        data: process.env,
      })
    );

    return config;
  },
};
```

`.gitignore`

```diff
+/public/[output]
```

## license

[MIT](./LICENSE)

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