{"name":"webpack-stats-plugin","version":"0.0.3","description":"Webpack stats plugin","main":"webpack-stats-plugin.js","dependencies":{},"devDependencies":{"gulp":"3.8.10","gulp-eslint":"0.2.2","gulp-jscs":"1.4.0","gulp-mdox":"0.0.2"},"repository":{"type":"git","url":"https://github.com/FormidableLabs/webpack-stats-plugin"},"keywords":["webpack"],"author":{"name":"Ryan Roemer","email":"ryan.roemer@formidablelabs.com"},"license":"MIT","bugs":{"url":"https://github.com/FormidableLabs/webpack-stats-plugin/issues"},"scripts":{"test":"gulp check"},"gitHead":"2a9b908b27f1cad924508df82a00437bb3eb9d26","homepage":"https://github.com/FormidableLabs/webpack-stats-plugin","_id":"webpack-stats-plugin@0.0.3","_shasum":"d5f27bc5e67bcdc8148527cb26f8e35571df34d6","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"ryan.roemer","email":"ryan@loose-bits.com"},"maintainers":[{"name":"ryan.roemer","email":"ryan@loose-bits.com"}],"dist":{"shasum":"d5f27bc5e67bcdc8148527cb26f8e35571df34d6","tarball":"http://registry-npm.ywwl.com/webpack-stats-plugin/download/webpack-stats-plugin-0.0.3.tgz","integrity":"sha512-a8Mq8Ow33IrO4TpqGIep5YMzg8bNev3TIGi3cZT3VmR52z24mJ0V7eDc6fOB76WaEhG7y8yU/aMHA0XXbGrbDQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCZdwd013A8VaJehIHgtPbYjkHu0YMQ+CP33dyCjMZuKAIgEGzChu0FRizayumdbgbDR2LhIfFKfGfVCMrIFdoxxHA="}],"size":8479,"noattachment":false,"key":"/webpack-stats-plugin/-/webpack-stats-plugin-0.0.3.tgz"},"directories":{},"readme":"[![Webpack Stats Plugin — Formidable, We build the modern web](https://raw.githubusercontent.com/FormidableLabs/webpack-stats-plugin/master/webpack-stats-plugin-Hero.png)](https://formidable.com/open-source/)\n\n[![npm version][npm_img]][npm_site]\n[![Actions Status][actions_img]][actions_site]\n[![MIT license][lic_img]][lic_site]\n[![Maintenance Status][maintenance_image]](#maintenance-status)\n\nThis plugin will ingest the webpack [stats](https://webpack.js.org/configuration/stats/#stats) object, process / transform the object and write out to a file for further consumption.\n\nThe most common use case is building a hashed bundle and wanting to programmatically refer to the correct bundle path in your Node.js server.\n\n## Installation\n\nThe plugin is available via [npm](https://www.npmjs.com/package/webpack-stats-plugin):\n\n```sh\n$ npm install --save-dev webpack-stats-plugin\n$ yarn add --dev webpack-stats-plugin\n```\n\n## Examples\n\nWe have example webpack configurations for all versions of webpack. See., e.g. [`test/scenarios/webpack5/webpack.config.js`](test/scenarios/webpack5/webpack.config.js).\n\n### CLI\n\nIf you are using `webpack-cli`, you can enable with:\n\n```sh\n$ webpack-cli --plugin webpack-stats-plugin/lib/stats-writer-plugin\n```\n\n### Basic\n\nA basic `webpack.config.js`-based integration:\n\n```js\nconst { StatsWriterPlugin } = require(\"webpack-stats-plugin\");\n\nmodule.exports = {\n  plugins: [\n    // Everything else **first**.\n\n    // Write out stats file to build directory.\n    new StatsWriterPlugin({\n      filename: \"stats.json\", // Default\n    }),\n  ],\n};\n```\n\n### Custom `stats` Configuration\n\nThis option is passed to the webpack compiler's [`getStats().toJson()`](https://webpack.js.org/api/node/#statstojsonoptions) method.\n\n```js\nconst { StatsWriterPlugin } = require(\"webpack-stats-plugin\");\n\nmodule.exports = {\n  plugins: [\n    new StatsWriterPlugin({\n      stats: {\n        all: false,\n        assets: true,\n      },\n    }),\n  ],\n};\n```\n\n### Custom Transform Function\n\nThe transform function has a signature of:\n\n```js\n/**\n * Transform skeleton.\n *\n * @param {Object} data           Stats object\n * @param {Object} opts           Options\n * @param {Object} opts.compiler  Current compiler instance\n * @returns {String}              String to emit to file\n */\nfunction (data, opts) {}\n```\n\nwhich you can use like:\n\n```js\nconst { StatsWriterPlugin } = require(\"webpack-stats-plugin\");\n\nmodule.exports = {\n  plugins: [\n    new StatsWriterPlugin({\n      transform(data, opts) {\n        return JSON.stringify(\n          {\n            main: data.assetsByChunkName.main[0],\n            css: data.assetsByChunkName.main[1],\n          },\n          null,\n          2\n        );\n      },\n    }),\n  ],\n};\n```\n\n### Promise transform\n\nYou can use an asynchronous promise to transform as well:\n\n```js\nconst { StatsWriterPlugin } = require(\"webpack-stats-plugin\");\n\nmodule.exports = {\n  plugins: [\n    new StatsWriterPlugin({\n      filename: \"stats-transform-promise.json\",\n      transform(data) {\n        return Promise.resolve().then(() =>\n          JSON.stringify(\n            {\n              main: data.assetsByChunkName.main,\n            },\n            null,\n            INDENT\n          )\n        );\n      },\n    }),\n  ],\n};\n```\n\n## Plugins\n\n- [`StatsWriterPlugin(opts)`](#statswriterplugin-opts-)\n\n### `StatsWriterPlugin(opts)`\n\n- **opts** (`Object`) options\n- **opts.filename** (`String|Function`) output file name (Default: `\"stats.json\"`)\n- **opts.fields** (`Array`) fields of stats obj to keep (Default: `[\"assetsByChunkName\"]`)\n- **opts.stats** (`Object|String`) stats config object or string preset (Default: `{}`)\n- **opts.transform** (`Function|Promise`) transform stats obj (Default: `JSON.stringify()`)\n- **opts.emit** (`Boolean`) add stats file to webpack output? (Default: `true`)\n\nStats writer module.\n\nStats can be a string or array (we'll have an array due to source maps):\n\n```js\n\"assetsByChunkName\": {\n  \"main\": [\n    \"cd6371d4131fbfbefaa7.bundle.js\",\n    \"../js-map/cd6371d4131fbfbefaa7.bundle.js.map\"\n  ]\n},\n```\n\n**`fields`, `stats`**\n\nThe stats object is **big**. It includes the entire source included in a bundle. Thus, we default `opts.fields` to `[\"assetsByChunkName\"]` to only include those. However, if you want the _whole thing_ (maybe doing an `opts.transform` function), then you can set `fields: null` in options to get **all** of the stats object.\n\nYou may also pass a custom stats config object (or string preset) via `opts.stats` in order to select exactly what you want added to the data passed to the transform. When `opts.stats` is passed, `opts.fields` will default to `null`.\n\nSee:\n\n- https://webpack.js.org/configuration/stats/#stats\n- https://webpack.js.org/api/node/#stats-object\n\n**`filename`**\n\nThe `opts.filename` option can be a file name or path relative to `output.path` in webpack configuration. It should not be absolute. It may also be a function, in which case it will be passed the current compiler instance and expected to return a filename to use.\n\n**`transform`**\n\nBy default, the retrieved stats object is `JSON.stringify`'ed:\n\n```javascript\nnew StatsWriterPlugin({\n  transform(data) {\n    return JSON.stringify(data, null, 2);\n  },\n});\n```\n\nBy supplying an alternate transform you can target _any_ output format. See [`test/scenarios/webpack5/webpack.config.js`](test/scenarios/webpack5/webpack.config.js) for various examples including Markdown output.\n\n- **Warning**: The output of `transform` should be a `String`, not an object. On Node `v4.x` if you return a real object in `transform`, then webpack will break with a `TypeError` (See [#8](https://github.com/FormidableLabs/webpack-stats-plugin/issues/8)). Just adding a simple `JSON.stringify()` around your object is usually what you need to solve any problems.\n\n**Internal notes**\n\nIn modern webpack, the plugin uses the [`processAssets`](https://webpack.js.org/api/compilation-hooks/#processassets) compilation hook if available when adding the stats object file to the overall compilation to write out along with all the other webpack-built assets. This is the [last possible place](https://github.com/webpack/webpack/blob/f2f998b58362d5edc9945a48f8245a3347ad007c/lib/Compilation.js#L2000-L2007) to hook in before the compilation is frozen in future webpack releases.\n\nIn earlier webpack, the plugin uses the much later [`emit`](https://webpack.js.org/api/compiler-hooks/#emit) compiler hook. There are technically some assets/stats data that could be added after `processAssets` and before `emit`, but for most practical uses of this plugin users shouldn't see any differences in the usable data produced by different versions of webpack.\n\n## Maintenance Status\n\n**Active:** Formidable is actively working on this project, and we expect to continue for work for the foreseeable future. Bug reports, feature requests and pull requests are welcome.\n\n[npm_img]: https://badge.fury.io/js/webpack-stats-plugin.svg\n[npm_site]: http://badge.fury.io/js/webpack-stats-plugin\n[actions_img]: https://github.com/FormidableLabs/webpack-stats-plugin/workflows/CI/badge.svg\n[actions_site]: https://github.com/FormidableLabs/webpack-stats-plugin/actions\n[lic_img]: https://img.shields.io/npm/l/webpack-stats-plugin.svg?color=brightgreen&style=flat\n[lic_site]: https://github.com/FormidableLabs/webpack-stats-plugin/blob/main/LICENSE.txt\n[maintenance_image]: https://img.shields.io/badge/maintenance-active-green.svg?color=brightgreen&style=flat\n","publish_time":1423510469391,"_cnpm_publish_time":1423510469391,"dist-tags":{"latest":"1.1.3"}}