{"name":"webpack-stats-plugin","version":"0.3.2","description":"Webpack stats plugin","main":"index.js","repository":{"type":"git","url":"git+https://github.com/FormidableLabs/webpack-stats-plugin.git"},"keywords":["webpack"],"author":{"name":"Ryan Roemer","email":"ryan.roemer@formidable.com"},"license":"MIT","bugs":{"url":"https://github.com/FormidableLabs/webpack-stats-plugin/issues"},"engines":{"node":">=4"},"scripts":{"lint":"eslint .","test":"yarn run test:clean && yarn run test:build && yarn run test:run","test:run":"mocha 'test/**/*.spec.js'","test:clean":"rm -rf test/webpack*/build*","test:build:single":"cd node_modules/webpack${VERS} && node index.js --config ../../test/webpack${VERS}/webpack.config${WP_EXTRA}.js","test:build":"builder envs test:build:single '[{\"VERS\":1},{\"VERS\":2},{\"VERS\":3},{\"VERS\":4}]' --buffer","check":"yarn run lint && yarn run test"},"dependencies":{},"devDependencies":{"babel-eslint":"^10.1.0","builder":"^5.0.0","chai":"^4.2.0","eslint":"^7.2.0","eslint-config-formidable":"^4.0.0","eslint-plugin-filenames":"^1.3.2","eslint-plugin-import":"^2.21.2","eslint-plugin-promise":"^4.2.1","mocha":"^8.0.1","pify":"^5.0.0","webpack1":"file:test/webpack1","webpack2":"file:test/webpack2","webpack3":"file:test/webpack3","webpack4":"file:test/webpack4"},"gitHead":"ce689d301e2a7657424e0604a329bea558191565","homepage":"https://github.com/FormidableLabs/webpack-stats-plugin#readme","_id":"webpack-stats-plugin@0.3.2","_nodeVersion":"12.14.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-kxEtPQ6lBBik2qtJlsZkiaDMI6rGXe9w1kLH9ZCdt0wgCGVnbwwPlP60cMqG6tILNFYqXDxNt4+c4OIIuE+Fnw==","shasum":"c06b185aa5dcc93b3f0c3a7891d24a111f849740","tarball":"http://registry-npm.ywwl.com/webpack-stats-plugin/download/webpack-stats-plugin-0.3.2.tgz","fileCount":6,"unpackedSize":16163,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe6oaJCRA9TVsSAnZWagAAfwYP/iftkvcLG8QGJGaGAJFO\nmQtGzAHyh/lNo0W+zt7nrjd/Thzo1R4mhij305QuIEfoV0lcyO18SM+YmvJs\nTvcHCuiIE1mjRqZvL2jTTfN/kpSq+CspnTBz6PdjzKObaIKDQISHirpbfeD9\nkJewUw+q7qaiUopLaNhzDjxHD9egayLoKCNz6A3RfAoNxY1Jou2zSS4O2a4G\nJ9rdvK5ysR7jk8JNgximkRv815NJNh22GzyFy3PSsl8tFttcXfg1ut1ynC6j\nBVLMGLS+gYveHrvdiVV1RcxFCrARFtML4Ovyz3Im/I9PQziu79fpNAlSh6tB\nyNjPYaTxgVQlXmdxdGoWVxgxAI2X78DJnaF1+tqveXvhD3Z+j0VbkmWLk4qy\ndEDjqXd5KXB87ac1XBdOphbVKxhoLuIXJpslfwcKgl2HKENPSpe1y9aH/XPf\n+vcjU2neX/0vbr+/pX09KqUOs6Fx3G1sJEi7QSKdtIk0cEipz4OCwFo2f8y2\nR7T/i/1cTtyGkhtepx7hR1LVXtIJe75WGrpmQrI6oBsPa56too7pJSomFohB\n4kWfAlhlNPIMn21ZJBgnLuP3QgODDVZsWtcLyaPy1fZDEAAGyIUrSoGm0v3s\nRo6WblDRzz10zO1PhP7kOUF2iPYRecCs+/712ZCd0+U+u7WQ8yV479x2ceqo\nBUba\r\n=nXP4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDKqLnEvUcqanOWpYVdFrW+aQ5LGOGqFbfsBP+Vm0kV4gIgUL0vYVRrEEzUN5Of5vyBEfm2oLsPw8G7y/qkuuZBX3M="}],"size":5562,"noattachment":false,"key":"/webpack-stats-plugin/-/webpack-stats-plugin-0.3.2.tgz"},"maintainers":[{"email":"andy.john.richardson@gmail.com","name":"andyrichardson"},{"email":"spoonart@gmail.com","name":"bmathews"},{"email":"lauren.eastridge@formidable.com","name":"boygirl"},{"email":"carbonrobot@gmail.com","name":"carbonrobot"},{"email":"me@carlos.dev","name":"carlospaelinck"},{"email":"bolin.chris@gmail.com","name":"chrisbolin"},{"email":"per@sproutlab.com","name":"coopy"},{"email":"ryan@eastridge.me","name":"eastridge"},{"email":"emma.brillhart@gmail.com","name":"ebrillhart"},{"email":"exogen@gmail.com","name":"exogen"},{"email":"admin@formidablelabs.com","name":"formidable-owner"},{"email":"npm@formidablelabs.com","name":"formidablelabs"},{"email":"brianhartz@gmail.com","name":"hartzis"},{"email":"imranolas@gmail.com","name":"imranolas"},{"email":"jrwilson@gmail.com","name":"jason.wilson"},{"email":"jmcbee1@gmail.com","name":"jmcbee1"},{"email":"kylieastewart@gmail.com","name":"kale-stew"},{"email":"kara.stubbs@formidable.com","name":"kiraarghy"},{"email":"jen.luker@formidable.com","name":"knitcodemonkey"},{"email":"kyle@kylecesmat.com","name":"kylecesmat"},{"email":"mariano.martinez@formidable.com","name":"mariano-formidable"},{"email":"monet.fulgham@formidable.com","name":"mfulgham"},{"email":"mhink1103@gmail.com","name":"mhink"},{"email":"michael@michaelmerrill.me","name":"michaelmerrill"},{"email":"parker.ziegler@formidable.com","name":"parkerziegler"},{"email":"lavalle.paula@gmail.com","name":"paulathevalley"},{"email":"phil@kitten.sh","name":"philpl"},{"email":"ryan@loose-bits.com","name":"ryan.roemer"},{"email":"ryanrray@gmail.com","name":"ryanisinallofus"},{"email":"samuelestrella226@gmail.com","name":"samwhale"},{"email":"sarahmichellemeyer@gmail.com","name":"sarmeyer"},{"email":"huynh.stefan@gmail.com","name":"stefvhuynh"},{"email":"ken_wheeler@me.com","name":"thekenwheeler"},{"email":"tyler@tylerpaulthompson.com","name":"tptee"}],"_npmUser":{"name":"ryan.roemer","email":"ryan@loose-bits.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/webpack-stats-plugin_0.3.2_1592428169141_0.9823653040543592"},"_hasShrinkwrap":false,"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":1592428169286,"_cnpm_publish_time":1592428169286,"dist-tags":{"latest":"1.1.3"}}