[
  {
    "path": ".editorconfig",
    "content": "#\n# EditorConfig: http://EditorConfig.org\n#\n# This files specifies some basic editor conventions for the files in this\n# project. Many editors support this standard, you simply need to find a plugin\n# for your favorite!\n#\n# For a full list of possible values consult the reference.\n# https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties\n#\n\n# Stop searching for other .editorconfig files above this folder.\nroot = true\n\n# Pick some sane defaults for all files.\n[*]\n\n# UNIX line-endings are preferred since:\n# * git prefers them\n# * servers run on Linux\n# * most developers use Mac OS X\n# http://adaptivepatchwork.com/2012/03/01/mind-the-end-of-your-line/\nend_of_line = lf\n\n# No reason in these modern times to use anything other than UTF-8.\ncharset = utf-8\n\n# Ensure that there's no bogus whitespace in the file.\ntrim_trailing_whitespace = true\n\n# A little esoteric, but it's kind of a standard now.\n# http://stackoverflow.com/questions/729692/why-should-files-end-with-a-newline\ninsert_final_newline = true\n\n# Herein be the apex of holy wars. For more information see:\n# http://programmers.stackexchange.com/questions/57\nindent_style = space\n\n# Personal preference here. Smaller indent size means you can fit more on a line\n# which can be nice when there are lines with several indentations.\nindent_size = 2\n\n# Prefer a more conservative default line length – this allows editors with\n# sidebars, minimaps, etc. to show at least two documents side-by-side.\n# Hard wrapping by default for code is useful since many editors don't support\n# an elegant soft wrap; however, soft wrap is fine for things where text just\n# flows normally, like Markdown documents or git commit messages. Hard wrap\n# is also easier for line-based diffing tools to consume.\n# See: http://tex.stackexchange.com/questions/54140\nmax_line_length = 80\n"
  },
  {
    "path": ".eslintignore",
    "content": "test/fixtures\ntest/output\ntest/new-output\nnode_modules\n"
  },
  {
    "path": ".eslintrc",
    "content": "{\n  \"extends\": \"standard\"\n}\n"
  },
  {
    "path": ".gitignore",
    "content": "/node_modules/\n/test/output/\n/test/new-output/\n*.log\n"
  },
  {
    "path": ".npmignore",
    "content": "/.*\n/test/\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: node_js\nnode_js:\n  - '6'\n\ndeploy:\n  provider: npm\n  email: unindented@gmail.com\n  api_key:\n    secure: KtlB4jwkf4faKoBWOztL4bQyg7Tqc4fW0zSYefQyr2qsEfz89v7SOEhZQ4Y3npc1EeTLKK0Q3bnKLlsh22TfeJWHid4snSgLmC8H6yGtGBPuGfskKCfAYlVhSr3pbpFeKZyvfJVrLHjq9iE6ks8fdZ/5IIY/fOb1htaMPtPpLAE=\n  on:\n    tags: true\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright (c) 2014 Daniel Perez Alvarez\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# Stats plugin for webpack [![Version](https://img.shields.io/npm/v/stats-webpack-plugin.svg)](https://www.npmjs.com/package/stats-webpack-plugin) [![Build Status](https://img.shields.io/travis/unindented/stats-webpack-plugin.svg)](http://travis-ci.org/unindented/stats-webpack-plugin) [![Dependency Status](https://img.shields.io/gemnasium/unindented/stats-webpack-plugin.svg)](https://gemnasium.com/unindented/stats-webpack-plugin)\n\nWrites the stats of a build to a file.\n\n\n## Installation\n\n```sh\n$ npm install --save-dev stats-webpack-plugin\n```\n\n\n## Usage\n\n```js\nvar StatsPlugin = require('stats-webpack-plugin');\n\nmodule.exports = {\n  plugins: [\n    new StatsPlugin('stats.json', {\n      chunkModules: true,\n      exclude: [/node_modules[\\\\\\/]react/]\n    })\n  ]\n};\n```\n\nGive webpack the `--profile` flag or set `profile: true` in `webpack.config` to get detailed timing measurements.\nSee [Webpack Profiling](https://webpack.github.io/docs/cli.html#profiling) for more detail.\n\n## API\n\n```js\nnew StatsPlugin(path: string, [options])\n```\n\n* `path`: The path of the result file, relative to your output folder.\n* `options`: Options passed to [stats.toJson](https://webpack.js.org/api/node/#stats-object)\n\n\n## Meta\n\n* Code: `git clone git://github.com/unindented/stats-webpack-plugin.git`\n* Home: <https://github.com/unindented/stats-webpack-plugin/>\n\n\n## Contributors\n\n* Daniel Perez Alvarez ([unindented@gmail.com](mailto:unindented@gmail.com))\n* Izaak Schroeder ([izaak.schroeder@gmail.com](mailto:izaak.schroeder@gmail.com))\n\n\n## License\n\nCopyright (c) 2014 Daniel Perez Alvarez ([unindented.org](https://unindented.org/)). This is free software, and may be redistributed under the terms specified in the LICENSE file.\n"
  },
  {
    "path": "index.js",
    "content": "var _ = require('lodash')\n\n/**\n * Create a new StatsPlugin that causes webpack to generate a stats file as\n * part of the emitted assets.\n * @constructor\n * @param {String} output Path to output file.\n * @param {Object} options Options passed to the stats' `.toJson()`.\n */\n\nfunction StatsPlugin (output, options, cache) {\n  this.output = output\n  this.options = options\n  this.cache = cache\n}\n\nfunction onEmit (output, options, cache) {\n  return function (compilation, done) {\n    var result\n\n    compilation.assets[output] = {\n      size: function getSize () {\n        return result ? result.length : 0\n      },\n      source: function getSource () {\n        var stats = compilation.getStats().toJson(options)\n        var result\n\n        if (cache) {\n          cache = _.merge(cache, stats)\n          if (stats.errors) cache.errors = stats.errors\n          if (stats.warnings) cache.warnings = stats.warnings\n          result = JSON.stringify(cache)\n        } else {\n          result = JSON.stringify(stats)\n        }\n        return result\n      }\n    }\n    done()\n  }\n}\n\nStatsPlugin.prototype.apply = function apply (compiler) {\n  var output = this.output\n  var options = this.options\n  var cache = this.cache\n\n  var onEmitCallback = onEmit(output, options, cache)\n\n  if (compiler.hooks) {\n    compiler.hooks.emit.tapAsync('StatsPlugin', onEmitCallback)\n  } else {\n    compiler.plugin('emit', onEmitCallback)\n  }\n}\n\nmodule.exports = StatsPlugin\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"stats-webpack-plugin\",\n  \"description\": \"Write the stats of a build to a file.\",\n  \"version\": \"0.7.0\",\n  \"license\": \"MIT\",\n  \"author\": {\n    \"name\": \"Daniel Perez Alvarez\",\n    \"email\": \"unindented@gmail.com\",\n    \"url\": \"http://unindented.org/\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git://github.com/unindented/stats-webpack-plugin.git\"\n  },\n  \"keywords\": [\n    \"stats\",\n    \"webpack\"\n  ],\n  \"scripts\": {\n    \"spec\": \"mocha\",\n    \"lint\": \"eslint .\",\n    \"test\": \"npm run lint && npm run spec\"\n  },\n  \"peerDependencies\": {\n    \"webpack\": \">=1.0.0\"\n  },\n  \"devDependencies\": {\n    \"chai\": \"^4.1.2\",\n    \"eslint\": \"^4.15.0\",\n    \"eslint-config-standard\": \"^10.2.1\",\n    \"eslint-plugin-import\": \"^2.8.0\",\n    \"eslint-plugin-node\": \"^5.2.1\",\n    \"eslint-plugin-promise\": \"^3.6.0\",\n    \"eslint-plugin-standard\": \"^3.0.1\",\n    \"mocha\": \"^5.0.0\",\n    \"node-libs-browser\": \"^2.1.0\",\n    \"rimraf\": \"^2.6.2\",\n    \"webpack\": \"^3.10.0\"\n  },\n  \"dependencies\": {\n    \"lodash\": \"^4.17.4\"\n  }\n}\n"
  },
  {
    "path": "test/.eslintrc",
    "content": "{\n  \"env\": {\n    \"mocha\": true\n  }\n}\n"
  },
  {
    "path": "test/fixtures/entry.js",
    "content": "var greeter = require('./greeter')\nconsole.log(greeter.greet('Daniel'))\n"
  },
  {
    "path": "test/fixtures/greeter.js",
    "content": "module.exports = {\n  greet: function (name) {\n    return 'Hello ' + name\n  }\n}\n"
  },
  {
    "path": "test/plugin.js",
    "content": "var fs = require('fs')\nvar path = require('path')\nvar rimraf = require('rimraf')\nvar webpack = require('webpack')\nvar StatsPlugin = require('../')\n\nvar chai = require('chai')\nvar expect = chai.expect\n\nvar inputFolder = path.resolve(__dirname, 'fixtures')\nvar inputFile = path.resolve(inputFolder, 'entry.js')\nvar outputFolder = path.resolve(__dirname, 'output')\nvar outputFile = path.resolve(outputFolder, 'stats.json')\n\nvar options = {\n  chunkModules: true,\n  exclude: [/node_modules[\\\\/]/]\n}\n\nvar defaultCompilerOptions = {\n  entry: inputFile,\n\n  output: {\n    path: outputFolder,\n    filename: 'bundle.js'\n  },\n\n  profile: true,\n\n  plugins: [\n    new StatsPlugin('stats.json', options)\n  ]\n}\n\nvar multiCompilerOptions = (cache) => [{\n  entry: {\n    file1: inputFile\n  },\n\n  output: {\n    path: outputFolder,\n    filename: 'bundle1.js'\n  },\n\n  profile: true,\n\n  plugins: [\n    new StatsPlugin('stats.json', options, cache)\n  ]\n}, {\n  entry: {\n    file2: inputFile\n  },\n\n  output: {\n    path: outputFolder,\n    filename: 'bundle2.js'\n  },\n\n  profile: true,\n\n  plugins: [\n    new StatsPlugin('stats.json', options, cache)\n  ]\n}]\n\ndescribe('StatsWebpackPlugin', function () {\n  beforeEach(function () {\n    rimraf.sync(outputFolder)\n  })\n\n  it('generates `stats.json` file', function (done) {\n    var compiler = webpack(defaultCompilerOptions)\n    compiler.run(function (err, stats) {\n      if (err) {\n        return done(err)\n      }\n\n      var actual = JSON.parse(fs.readFileSync(outputFile, 'utf8'))\n      var expected = stats.toJson(options)\n\n      expect(actual.assets.length).to.equal(expected.assets.length)\n      done()\n    })\n  })\n\n  it('supports multi-compile mode and outputs one `stats.json` file', function (done) {\n    var cache = {}\n    var compiler = webpack(multiCompilerOptions(cache))\n    compiler.run(function (err, stats) {\n      if (err) {\n        return done(err)\n      }\n\n      var actual = JSON.parse(fs.readFileSync(outputFile, 'utf8'))\n\n      var expectedAssetsByChunkName = {\n        file1: 'bundle1.js',\n        file2: 'bundle2.js'\n      }\n      expect(actual.assetsByChunkName).to.deep.equal(expectedAssetsByChunkName)\n      done()\n    })\n  })\n})\n"
  }
]