# env-info-webpack-plugin

> Webpack plugin for generates build and env information.

Latest version **1.0.0** (published 2021-04-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install env-info-webpack-plugin
pnpm add env-info-webpack-plugin
yarn add env-info-webpack-plugin
bun add env-info-webpack-plugin
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-04-27 |
| First published | 2019-05-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 12.4 KB |
| Known vulnerabilities | 0 (+4 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | sqrtthree |
| Maintainers | sqrtthree |

## Links

- npm: https://www.npmjs.com/package/env-info-webpack-plugin
- Repository: https://github.com/sqrthree/env-info-webpack-plugin
- Homepage: https://github.com/sqrthree/env-info-webpack-plugin#readme
- Issues: https://github.com/sqrthree/env-info-webpack-plugin/issues
- npm.io page: https://npm.io/package/env-info-webpack-plugin

## Dependencies (4)

- [lodash](https://npm.io/package/lodash.md) ~4.17.21
- [pkg-up](https://npm.io/package/pkg-up.md) ^3.1.0
- [webpack](https://npm.io/package/webpack.md) ~5.35.1
- [webpack-sources](https://npm.io/package/webpack-sources.md) ~2.2.0

## Recent versions

- 1.0.0 (latest) — 2021-04-27
- 0.3.2 — 2020-04-19
- 0.3.0 — 2020-02-05
- 0.2.0 — 2019-09-04
- 0.1.0 — 2019-05-27

## README

[![npm](https://img.shields.io/npm/v/env-info-webpack-plugin.svg?style=?style=flat&logo=appveyor)](https://www.npmjs.com/package/env-info-webpack-plugin)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=?style=flat&logo=appveyor)](http://makeapullrequest.com)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=?style=flat&logo=appveyor)](https://github.com/sqrthree/env-info-webpack-plugin/blob/master/LICENSE)

# env-info-webpack-plugin

Webpack plugin for generates building and env information.

![image](https://user-images.githubusercontent.com/8622362/62819515-e006d000-bb88-11e9-88d8-e9e535a92e6f.png)

## Getting started

Install with npm:

```shell
npm i --save-dev env-info-webpack-plugin
```

Install with yarn:

```shell
yarn add --dev env-info-webpack-plugin
```

### Prerequisites

- [webpack](https://github.com/webpack/webpack)

## Usage

1. Enable plugin in your `webpack.config.js` file:

```js
const EnvInfoPlugin = require('env-info-webpack-plugin')

module.exports = {
  entry: 'index.js',
  output: {
    path: __dirname + '/dist',
    filename: 'bundle.js',
  },
  plugins: [new EnvInfoPlugin()],
}
```

2 Output info into console in your entry file, eg: `app.js`:

```js
console.log(BUILD_INFO) // BUILD_INFO will be replaced with env info when building with webpack.

console.log(
  `%c${BUILD_INFO.name}%cv${BUILD_INFO.version}`,
  'background: #35495e; color: #fff; padding: 2px 4px; border-radius: 3px 0 0 3px;',
  'background: #19be6b; color: #fff; padding: 2px 4px; border-radius: 0 3px 3px 0;'
) // Output with colorful support.

/*

BUILD_INFO => {
  name: 'Your Project Name',
  version: '0.1.0',
  time: '2019-05-27T15:49:46.162Z',
  hash: '035d7e36be302121871cf907e292269071a0c2f4',
}

*/
```

##### If you are using vue-cli

```js
// 1. Working with Webpack in vue.config.js
const EnvInfoPlugin = require('env-info-webpack-plugin')

module.exports = {
  // ...Your own config.

  configureWebpack: {
    plugins: [new EnvInfoPlugin()],
  },
}

// 2. Output info in main.js
console.log(
  `%c${BUILD_INFO.name}%cv${BUILD_INFO.version}`,
  'background: #35495e; color: #fff; padding: 2px 4px; border-radius: 3px 0 0 3px;',
  'background: #19be6b; color: #fff; padding: 2px 4px; border-radius: 0 3px 3px 0;'
) // Output with colorful support.
```

## Options

### name

Type: `string`

Global constant name for env info, the default is `BUILD_INFO`.

### output

Type: `boolean | string`

Global constant name for env info, the default is `false`, it will be _Options.name_ if the output is `true`.

### persistent

Type: `boolean | string`

Persistent storage to local file. If a string is given, it will be as name of output file.

---

> [sqrtthree.com](http://sqrtthree.com/) &nbsp;&middot;&nbsp;
> GitHub [@sqrthree](https://github.com/sqrthree) &nbsp;&middot;&nbsp;
> Twitter [@sqrtthree](https://twitter.com/sqrtthree)

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