# kamikazept-chunks-2-json-webpack-plugin

> Plugin for webpack 4, that outputs build files to JSON

Latest version **1.0.2** (published 2019-02-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install kamikazept-chunks-2-json-webpack-plugin
pnpm add kamikazept-chunks-2-json-webpack-plugin
yarn add kamikazept-chunks-2-json-webpack-plugin
bun add kamikazept-chunks-2-json-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.2 |
| Published | 2019-02-06 |
| First published | 2019-01-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10.0.0 |
| Dependencies | 3 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Afonso Santos aka kamikazePT |
| Maintainers | kamikazept |
| Keywords | webpack4, dependency, JSON, webpack, file, list |

## Links

- npm: https://www.npmjs.com/package/kamikazept-chunks-2-json-webpack-plugin
- Repository: https://github.com/kamikazePT/chunks-2-json-webpack-plugin
- Homepage: https://github.com/kamikazePT/chunks-2-json-webpack-plugin#readme
- Issues: https://github.com/kamikazePT/chunks-2-json-webpack-plugin/issues
- npm.io page: https://npm.io/package/kamikazept-chunks-2-json-webpack-plugin

## Dependencies (3)

- [fs](https://npm.io/package/fs.md) ^0.0.1-security
- [path](https://npm.io/package/path.md) ^0.12.7
- [lodash.isnil](https://npm.io/package/lodash.isnil.md) ^4.0.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.2 (latest) — 2019-02-06
- 1.0.1 — 2019-02-05
- 1.0.0 — 2019-01-30

## README

# chunks-2-json-webpack-plugin
Plugin for webpack 4, that outputs build files to JSON

## Instalation 

```
yarn add --dev kamikazept-chunks-2-json-webpack-plugin
```

## Use case

Webpack is a great tool and has without a doubt revolutionized the way we build frontend applications. However usually, due to the (great) caching strategy, chunk files will have hash appended to their file name. And if you want to use your build in an env, that does not know 
anything about this, it becomes complicated to inject the build in your app.

Therefore this plugin was build, as it will output your chunks in a JSON file, that will 
allow other apps to understand the structure of the build. 


## Usage example

#### Input

```javascript

const Chunks2JsonPlugin = require('kamikazept-chunks-2-json-webpack-plugin');
const path = require('path');
const projectPath = process.cwd();

const scriptPath = path.resolve(projectPath, 'js');
const stylePath = path.resolve(projectPath, 'css')

module.exports = {
  entry: './path/to/my/entry/file.js',
  output: {
    filename: '[chunkhash].bundle.js',
    path: scriptPath,
    publicPath : '/js/'
  },
  plugins: [
    new MiniCssExtractPlugin({
      filename: path.join(path.relative(scriptPath, stylePath), '[chunkhash].css'))
    }),
    new Chunks2JsonPlugin()
  ]
};

```

#### Output

```JSON
{
  "chunk-vendors": {
    "js": ["/js/chunk-vendors.fc40696c.js"],
    "js.map": ["/js/chunk-vendors.fc40696c.js.map"]
  },
  "app": {
    "css": ["/css/app.eb829ccc.css"],
    "js": ["/js/app.dd31cdcb.js"],
    "js.map": ["/js/app.dd31cdcb.js.map"]
  }
}
```

## Options

| Option | Description |
| ------------- |-------------|
| excludeFile | `RegExp` or `function(filename, chunk definition object) => bool`. Exclude dynamic imported chunks and HMR chunks (file names ending with `.hot-update.js`) by default . |
| chunkGroupName | `function(filename, chunk definition object) => string`, generate chunk group name. Group by file extension (or `ext.map`) by default. |
| outputDir | Output folder name. If the folder does not exist, we'll try to create it. Current working directory by default.  |
| filename | Output file name. `build-manifest.json` by default. |
| isProduction | If true it will minify json, otherwise it will pretty print it. |

## Questions? 

Feel free to open an issue. 

## Notes

Will make PR to original repository

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