pax_global_header00006660000000000000000000000064131215217240014510gustar00rootroot0000000000000052 comment=0f66ce9f8a4db9871750a9e8c287b7b1ff943934 stats-webpack-plugin-0.6.1/000077500000000000000000000000001312152172400155605ustar00rootroot00000000000000stats-webpack-plugin-0.6.1/.editorconfig000066400000000000000000000034641312152172400202440ustar00rootroot00000000000000# # EditorConfig: http://EditorConfig.org # # This files specifies some basic editor conventions for the files in this # project. Many editors support this standard, you simply need to find a plugin # for your favorite! # # For a full list of possible values consult the reference. # https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties # # Stop searching for other .editorconfig files above this folder. root = true # Pick some sane defaults for all files. [*] # UNIX line-endings are preferred since: # * git prefers them # * servers run on Linux # * most developers use Mac OS X # http://adaptivepatchwork.com/2012/03/01/mind-the-end-of-your-line/ end_of_line = lf # No reason in these modern times to use anything other than UTF-8. charset = utf-8 # Ensure that there's no bogus whitespace in the file. trim_trailing_whitespace = true # A little esoteric, but it's kind of a standard now. # http://stackoverflow.com/questions/729692/why-should-files-end-with-a-newline insert_final_newline = true # Herein be the apex of holy wars. For more information see: # http://programmers.stackexchange.com/questions/57 indent_style = space # Personal preference here. Smaller indent size means you can fit more on a line # which can be nice when there are lines with several indentations. indent_size = 2 # Prefer a more conservative default line length – this allows editors with # sidebars, minimaps, etc. to show at least two documents side-by-side. # Hard wrapping by default for code is useful since many editors don't support # an elegant soft wrap; however, soft wrap is fine for things where text just # flows normally, like Markdown documents or git commit messages. Hard wrap # is also easier for line-based diffing tools to consume. # See: http://tex.stackexchange.com/questions/54140 max_line_length = 80 stats-webpack-plugin-0.6.1/.eslintignore000066400000000000000000000000671312152172400202660ustar00rootroot00000000000000test/fixtures test/output test/new-output node_modules stats-webpack-plugin-0.6.1/.eslintrc000066400000000000000000000000341312152172400174010ustar00rootroot00000000000000{ "extends": "standard" } stats-webpack-plugin-0.6.1/.gitignore000066400000000000000000000000651312152172400175510ustar00rootroot00000000000000/node_modules/ /test/output/ /test/new-output/ *.log stats-webpack-plugin-0.6.1/.npmignore000066400000000000000000000000131312152172400175510ustar00rootroot00000000000000/.* /test/ stats-webpack-plugin-0.6.1/.travis.yml000066400000000000000000000004631312152172400176740ustar00rootroot00000000000000language: node_js node_js: - '6' deploy: provider: npm email: unindented@gmail.com api_key: secure: KtlB4jwkf4faKoBWOztL4bQyg7Tqc4fW0zSYefQyr2qsEfz89v7SOEhZQ4Y3npc1EeTLKK0Q3bnKLlsh22TfeJWHid4snSgLmC8H6yGtGBPuGfskKCfAYlVhSr3pbpFeKZyvfJVrLHjq9iE6ks8fdZ/5IIY/fOb1htaMPtPpLAE= on: tags: true stats-webpack-plugin-0.6.1/LICENSE000066400000000000000000000020501312152172400165620ustar00rootroot00000000000000Copyright (c) 2014 Daniel Perez Alvarez Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. stats-webpack-plugin-0.6.1/README.md000066400000000000000000000033061312152172400170410ustar00rootroot00000000000000# 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) Writes the stats of a build to a file. ## Installation ```sh $ npm install --save stats-webpack-plugin ``` ## Usage ```js var StatsPlugin = require('stats-webpack-plugin'); module.exports = { plugins: [ new StatsPlugin('stats.json', { chunkModules: true, exclude: [/node_modules[\\\/]react/] }) ] }; ``` Give webpack the `--profile` flag or set `profile: true` in `webpack.config` to get detailed timing measurements. See [Webpack Profiling](https://webpack.github.io/docs/cli.html#profiling) for more detail. ## API ```js new StatsPlugin(path: string, [options]) ``` * `path`: The path of the result file, relative to your output folder. * `options`: Options passed to [stats.toJson](http://webpack.github.io/docs/node.js-api.html#stats-tojson) ## Meta * Code: `git clone git://github.com/unindented/stats-webpack-plugin.git` * Home: ## Contributors * Daniel Perez Alvarez ([unindented@gmail.com](mailto:unindented@gmail.com)) * Izaak Schroeder ([izaak.schroeder@gmail.com](mailto:izaak.schroeder@gmail.com)) ## License Copyright (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. stats-webpack-plugin-0.6.1/index.js000066400000000000000000000023121312152172400172230ustar00rootroot00000000000000var _ = require('lodash') /** * Create a new StatsPlugin that causes webpack to generate a stats file as * part of the emitted assets. * @constructor * @param {String} output Path to output file. * @param {Object} options Options passed to the stats' `.toJson()`. */ function StatsPlugin (output, options, cache) { this.output = output this.options = options this.cache = cache } StatsPlugin.prototype.apply = function apply (compiler) { var output = this.output var options = this.options var cache = this.cache compiler.plugin('emit', function onEmit (compilation, done) { var result compilation.assets[output] = { size: function getSize () { return result && result.length || 0 }, source: function getSource () { var stats = compilation.getStats().toJson(options) var result if (cache) { cache = _.merge(cache, stats) if (stats.errors) cache.errors = stats.errors if (stats.warnings) cache.warnings = stats.warnings result = JSON.stringify(cache) } else { result = JSON.stringify(stats) } return result } } done() }) } module.exports = StatsPlugin stats-webpack-plugin-0.6.1/package.json000066400000000000000000000016721312152172400200540ustar00rootroot00000000000000{ "name": "stats-webpack-plugin", "description": "Write the stats of a build to a file.", "version": "0.6.1", "license": "MIT", "author": { "name": "Daniel Perez Alvarez", "email": "unindented@gmail.com", "url": "http://unindented.org/" }, "repository": { "type": "git", "url": "git://github.com/unindented/stats-webpack-plugin.git" }, "keywords": [ "stats", "webpack" ], "scripts": { "spec": "mocha", "lint": "eslint .", "test": "npm run lint && npm run spec" }, "peerDependencies": { "webpack": "^1.0||^2.1.0-beta||^2.2.0-rc" }, "devDependencies": { "chai": "^3.5.0", "eslint": "^3.13.1", "eslint-config-standard": "^6.2.1", "eslint-plugin-promise": "^3.4.0", "eslint-plugin-standard": "^2.0.1", "mocha": "^3.2.0", "node-libs-browser": "^2.0.0", "rimraf": "^2.5.4", "webpack": "^1.14.0" }, "dependencies": { "lodash": "^4.17.4" } } stats-webpack-plugin-0.6.1/test/000077500000000000000000000000001312152172400165375ustar00rootroot00000000000000stats-webpack-plugin-0.6.1/test/.eslintrc000066400000000000000000000000451312152172400203620ustar00rootroot00000000000000{ "env": { "mocha": true } } stats-webpack-plugin-0.6.1/test/fixtures/000077500000000000000000000000001312152172400204105ustar00rootroot00000000000000stats-webpack-plugin-0.6.1/test/fixtures/entry.js000066400000000000000000000001101312152172400220770ustar00rootroot00000000000000var greeter = require('./greeter') console.log(greeter.greet('Daniel')) stats-webpack-plugin-0.6.1/test/fixtures/greeter.js000066400000000000000000000001171312152172400224020ustar00rootroot00000000000000module.exports = { greet: function (name) { return 'Hello ' + name } } stats-webpack-plugin-0.6.1/test/plugin.js000066400000000000000000000046711312152172400204030ustar00rootroot00000000000000var fs = require('fs') var path = require('path') var rimraf = require('rimraf') var webpack = require('webpack') var StatsPlugin = require('../') var chai = require('chai') var expect = chai.expect var inputFolder = path.resolve(__dirname, 'fixtures') var inputFile = path.resolve(inputFolder, 'entry.js') var outputFolder = path.resolve(__dirname, 'output') var outputFile = path.resolve(outputFolder, 'stats.json') var options = { chunkModules: true, exclude: [/node_modules[\\/]/] } var defaultCompilerOptions = { entry: inputFile, output: { path: outputFolder, filename: 'bundle.js' }, profile: true, plugins: [ new StatsPlugin('stats.json', options) ] } var multiCompilerOptions = (cache) => [{ entry: { file1: inputFile }, output: { path: outputFolder, filename: 'bundle1.js' }, profile: true, plugins: [ new StatsPlugin('stats.json', options, cache) ] }, { entry: { file2: inputFile }, output: { path: outputFolder, filename: 'bundle2.js' }, profile: true, plugins: [ new StatsPlugin('stats.json', options, cache) ] }] describe('StatsWebpackPlugin', function () { beforeEach(function () { rimraf.sync(outputFolder) }) it('generates `stats.json` file', function (done) { var compiler = webpack(defaultCompilerOptions) compiler.run(function (err, stats) { if (err) { return done(err) } var actual = JSON.parse(fs.readFileSync(outputFile, 'utf8')) var expected = stats.toJson(options) // Delete variable timing info. delete expected.time // Delete mismatched info. for (var i = 0, l = expected.assets.length; i < l; ++i) { if (expected.assets[i].name === 'stats.json') { delete expected.assets[i].emitted expected.assets[i].size = 0 break } } expect(actual).to.deep.equal(expected) done() }) }) it('supports multi-compile mode and outputs one `stats.json` file', function (done) { var cache = {} var compiler = webpack(multiCompilerOptions(cache)) compiler.run(function (err, stats) { if (err) { return done(err) } var actual = JSON.parse(fs.readFileSync(outputFile, 'utf8')) var expectedAssetsByChunkName = { file1: 'bundle1.js', file2: 'bundle2.js' } expect(actual.assetsByChunkName).to.deep.equal(expectedAssetsByChunkName) done() }) }) })