pax_global_header00006660000000000000000000000064130674443210014516gustar00rootroot0000000000000052 comment=6656c1028b9a985bcb9045b738170c5195217997 webpack-stats-plugin-0.1.5/000077500000000000000000000000001306744432100155655ustar00rootroot00000000000000webpack-stats-plugin-0.1.5/.editorconfig000066400000000000000000000001101306744432100202320ustar00rootroot00000000000000root = true [*.js] charset = utf-8 indent_style = space indent_size = 2webpack-stats-plugin-0.1.5/.eslintrc000066400000000000000000000366301306744432100174210ustar00rootroot00000000000000ecmaFeatures: jsx: true env: browser: false node: true amd: false mocha: false jasmine: false globals: require: true module: true rules: ########################################################################### # # # POSSIBLE ERRORS: these rules point out areas where you might have # # made mistakes. # # # ########################################################################### no-comma-dangle: 1 # disallow trailing commas in object literals no-cond-assign: 2 # disallow assignment in conditional expressions no-console: 2 # disallow use of console no-constant-condition: 2 # disallow use of constant expressions in conditions no-control-regex: 2 # disallow control characters in regular expressions no-debugger: 2 # disallow use of debugger no-dupe-keys: 2 # disallow duplicate keys when creating object literals no-empty: 2 # disallow empty statements no-empty-class: 2 # disallow the use of empty character classes in regular expressions no-ex-assign: 2 # disallow assigning to the exception in a catch block no-extra-boolean-cast: 2 # disallow double-negation boolean casts in a boolean context no-extra-parens: 0 # disallow unnecessary parentheses # NOTE: Allow for `return (/* JSX STUFF*/);` situations no-extra-semi: 2 # disallow unnecessary semicolons no-func-assign: 2 # disallow overwriting functions written as function declarations no-inner-declarations: 1 # disallow function or variable declarations in nested blocks no-invalid-regexp: 2 # disallow invalid regular expression strings in the RegExp # constructor no-irregular-whitespace: 2 # disallow irregular whitespace outside of strings and comments no-negated-in-lhs: 2 # disallow negation of the left operand of an in expression no-obj-calls: 2 # disallow the use of object properties of the global object (Math # and JSON) as functions no-regex-spaces: 1 # disallow multiple spaces in a regular expression literal no-reserved-keys: 1 # disallow reserved words being used as object literal keys no-sparse-arrays: 2 # disallow sparse arrays no-unreachable: 2 # disallow unreachable statements after a return, throw, continue, # or break statement use-isnan: 2 # disallow comparisons with the value NaN valid-typeof: 2 # ensure that the results of typeof are compared against a # valid string valid-jsdoc: # ensure JSDoc comments are valid [1, { "prefer": { "return": "returns" }, "requireReturn": false }] ########################################################################### # # # BEST PRACTICES: these rules are designed to prevent you from making # # mistakes. They either prescribe a better way of doing something or # # help you avoid pitfalls. # # # ########################################################################### block-scoped-var: 1 # treat var statements as if they were block scoped complexity: [1, 250] # specify the maximum cyclomatic complexity allowed in a program consistent-return: 0 # require return statements to either always or never specify values curly: 2 # specify curly brace conventions for all control statements default-case: 2 # require default case in switch statements dot-notation: 1 # encourages use of dot notation whenever possible eqeqeq: 2 # require the use of === and !== guard-for-in: 1 # make sure for-in loops have an if statement no-alert: 2 # disallow the use of alert, confirm, and prompt no-caller: 2 # disallow use of arguments.caller or arguments.callee no-div-regex: 1 # disallow division operators explicitly at beginning of regular # expression no-else-return: 1 # disallow else after a return in an if no-empty-label: 2 # disallow use of labels for anything other then loops and switches no-eq-null: 2 # disallow comparisons to null without a type-checking operator no-eval: 2 # disallow use of eval() no-extend-native: 2 # disallow adding to native types no-extra-bind: 2 # disallow unnecessary function binding no-fallthrough: 2 # disallow fallthrough of case statements no-floating-decimal: 2 # disallow the use of leading or trailing decimal points in numeric # literals no-implied-eval: 2 # disallow use of eval()-like methods no-iterator: 2 # disallow usage of __iterator__ property no-labels: 2 # disallow use of labeled statements no-lone-blocks: 2 # disallow unnecessary nested blocks no-loop-func: 0 # disallow creation of functions within loops no-multi-spaces: 0 # disallow use of multiple spaces no-multi-str: 2 # disallow use of multiline strings no-native-reassign: 2 # disallow reassignments of native objects no-new: 2 # disallow use of new operator when not part of the assignment or # comparison no-new-func: 2 # disallow use of new operator for Function object no-new-wrappers: 2 # disallows creating new instances of String,Number, and Boolean no-octal: 2 # disallow use of octal literals no-octal-escape: 2 # disallow use of octal escape sequences in string literals, such as # `var foo = "Copyright \251"` no-process-env: 0 # disallow use of process.env no-proto: 2 # disallow usage of __proto__ property no-redeclare: 1 # disallow declaring the same variable more then once no-return-assign: 0 # disallow use of assignment in return statement no-script-url: 2 # disallow use of javascript urls. no-self-compare: 2 # disallow comparisons where both sides are exactly the same no-sequences: 2 # disallow use of comma operator no-unused-expressions: 0 # disallow usage of expressions in statement position no-void: 2 # disallow use of void operator no-warning-comments: 0 # disallow usage of configurable warning terms in comments - e.g. # TODO or FIXME no-with: 2 # disallow use of the with statement radix: 2 # require use of the second argument for parseInt() vars-on-top: 0 # requires to declare all vars on top of their containing scope wrap-iife: [2, "inside"] # require immediate function invocation to be wrapped in parentheses yoda: "never" # require or disallow Yoda conditions ########################################################################### # # # STRICT MODE: these rules relate to using strict mode. # # # ########################################################################### global-strict: [2, "never"] # require or disallow the "use strict" pragma in the global scope no-extra-strict: 2 # disallow use of "use strict" when already in strict mode strict: 0 # require that all functions are run in strict mode ########################################################################### # # # VARIABLES: these rules have to do with variable declarations. # # # ########################################################################### no-catch-shadow: 2 # disallow the catch clause parameter name being the same as a # variable in the outer scope no-delete-var: 2 # disallow deletion of variables no-label-var: 2 # disallow labels that share a name with a variable no-shadow: 1 # disallow declaration of variables already declared in the # outer scope no-shadow-restricted-names: 2 # disallow shadowing of names such as arguments no-undef: 2 # disallow use of undeclared variables unless mentioned in a # /*global */ block no-undef-init: 2 # disallow use of undefined when initializing variables no-undefined: 2 # disallow use of undefined variable no-unused-vars: 2 # disallow declaration of variables that are not used in # the code no-use-before-define: 2 # disallow use of variables before they are defined ########################################################################### # # # NODE: these rules relate to functionality provided in Node.js. # # # ########################################################################### handle-callback-err: 0 # enforces error handling in callbacks no-mixed-requires: [1, true] # disallow mixing regular variable and require declarations no-new-require: 2 # disallow use of new operator with the require function no-path-concat: 2 # disallow string concatenation with __dirname and __filename no-process-exit: 0 # disallow process.exit() no-restricted-modules: 0 # restrict usage of specified node modules no-sync: 0 # disallow use of synchronous methods ########################################################################### # # # STYLISTIC ISSUES: these rules are purely matters of style and, # # while valueable to enforce consistently across a project, are # # quite subjective. # # # ########################################################################### brace-style: # enforce one true brace style [2, "1tbs", { "allowSingleLine": true }] camelcase: 2 # require camel case names comma-spacing: 2 # enforce spacing before and after comma comma-style: 2 # enforce one true comma style consistent-this: [2, "self"] # enforces consistent naming when capturing the current execution context eol-last: 2 # enforce newline at the end of file, with no multiple empty lines func-names: 0 # require function expressions to have a name func-style: 0 # enforces use of function declarations or expressions key-spacing: 2 # enforces spacing between keys and values in object literal properties max-nested-callbacks: [2, 4] # specify the maximum depth callbacks can be nested new-cap: 2 # require a capital letter for constructors new-parens: 2 # disallow the omission of parentheses when invoking a constructor with no arguments no-array-constructor: 2 # disallow use of the Array constructor no-lonely-if: 0 # disallow if as the only statement in an else block no-mixed-spaces-and-tabs: 2 # disallow mixed spaces and tabs for indentation no-nested-ternary: 2 # disallow nested ternary expressions no-new-object: 1 # disallow use of the Object constructor no-space-before-semi: 2 # disallow space before semicolon no-spaced-func: 2 # disallow space between function identifier and application no-ternary: 0 # disallow the use of ternary operators no-trailing-spaces: 2 # disallow trailing whitespace at the end of lines no-multiple-empty-lines: 2 # disallow multiple empty lines no-underscore-dangle: 0 # disallow dangling underscores in identifiers no-wrap-func: 2 # disallow wrapping of non-IIFE statements in parens one-var: 0 # allow just one var statement per function padded-blocks: 0 # enforce padding within blocks quotes: # specify whether double or single quotes should be used [1, "double", "avoid-escape"] quote-props: 0 # require quotes around object literal property names semi: [2, "always"] # require or disallow use of semicolons instead of ASI sort-vars: 0 # sort variables within the same declaration block space-after-keywords: "always" # require a space after certain keywords space-before-blocks: 2 # require or disallow space before blocks space-in-brackets: 0 # require or disallow spaces inside brackets space-in-parens: 0 # require or disallow spaces inside parentheses space-infix-ops: 2 # require spaces around operators space-return-throw-case: 2 # require a space after return, throw, and case spaced-line-comment: 2 # require or disallow a space immediately following # the // in a line comment wrap-regex: 0 # require regex literals to be wrapped in parentheses ########################################################################### # # # LEGACY: these rules are included for compatibility with JSHint and # # JSLint. While the names of the rules may not match up with their # # JSHint/JSLint counterpart, the functionality is the same. # # # ########################################################################### max-depth: 0 # specify the maximum depth that blocks can be nested max-len: [2, 100, 4] # specify the maximum length of a line in your program max-params: [1, 3] # limits the number of parameters that can be used in the function # declaration max-statements: 0 # specify the maximum number of statement allowed in a function no-bitwise: 0 # disallow use of bitwise operators no-plusplus: 0 # disallow use of unary operators, ++ and --webpack-stats-plugin-0.1.5/.gitignore000066400000000000000000000001741306744432100175570ustar00rootroot00000000000000\.git \.hg \.DS_Store \.project bower_components node_modules npm-debug\.log # Build coverage demo/stats.json demo/build* webpack-stats-plugin-0.1.5/.jscsrc000066400000000000000000000036571306744432100170700ustar00rootroot00000000000000{ "disallowOperatorBeforeLineBreak": ["."], "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], "requireCurlyBraces": [ "if", "else", "for", "while", "do", "try", "catch" ], "requireSpaceBeforeKeywords": [ "if", "else", "for", "while", "do", "switch", "case", "return", "try", "catch" ], "requireSpacesInFunctionExpression": { "beforeOpeningCurlyBrace": true, "beforeOpeningRoundBrace": true }, "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, "requireSpaceAfterLineComment": true, "requireSpaceBeforeObjectValues": true, "requireSpaceBetweenArguments": true, "requireSpaceAfterBinaryOperators": true, "requireSpaceBeforeBinaryOperators": true, "requireSpaceAfterKeywords": true, "requireSpaceBeforeBlockStatements": true, "requireSpacesInConditionalExpression": true, "requireSpacesInForStatement": true, "disallowSpaceAfterObjectKeys": true, "disallowSpacesInsideArrayBrackets": { "allExcept": [ "[", "]", "{", "}" ] }, "requireSpacesInsideObjectBrackets": "all", "disallowMixedSpacesAndTabs": true, "disallowMultipleLineBreaks": true, "disallowMultipleLineStrings": true, "disallowMultipleVarDecl": true, "disallowNewlineBeforeBlockStatements": true, "disallowQuotedKeysInObjects": "allButReserved", "disallowTrailingComma": true, "disallowTrailingWhitespace": true, "disallowSpacesInCallExpression": true, "requireCommaBeforeLineBreak": true, "requireSpacesInForStatement": true, "disallowEmptyBlocks": true, "disallowYodaConditions": true, "disallowKeywordsOnNewLine": ["else"], "requireCamelCaseOrUpperCaseIdentifiers": true, "requireCapitalizedConstructors": true, "requireOperatorBeforeLineBreak": true, "requireParenthesesAroundIIFE": true, "safeContextKeyword": ["self"], "validateIndentation": 2, "validateQuoteMarks": "\"" } webpack-stats-plugin-0.1.5/.travis.yml000066400000000000000000000002251306744432100176750ustar00rootroot00000000000000language: node_js node_js: - "0.10" - "0.12" sudo: false script: - node index.js - node_modules/.bin/gulp check:ci - npm run build-demo webpack-stats-plugin-0.1.5/HISTORY.md000066400000000000000000000020141306744432100172450ustar00rootroot00000000000000History ======= ## 0.1.5 * Slim down published npm package. (*[@evilebottnawi][]*) ## 0.1.4 * Add constructor definition. (*[@vlkosinov][]*) ## 0.1.3 * Add `opts.compiler` to transform function. [#15](https://github.com/FormidableLabs/webpack-stats-plugin/issues/15) (*[@lostrouter][]*) ## 0.1.2 * _Bad release_ ## 0.1.1 * Allow `opts.transform` to output arbitrary formats. (*[@tanem][]*) ## 0.1.0 * Emit stat file in compilation assets, allowing use in webpack-dev-server / webpack-stream. Fixes [#4](https://github.com/FormidableLabs/webpack-stats-plugin/issues/4) (*[@seanchas116][]*) ## 0.0.3 * Add `mkdir -p` functionality for `opts.path` directories. ## 0.0.2 * Actually works. ## 0.0.1 * Is embarassing and shall be forgotten. [@evilebottnawi]: https://github.com/evilebottnawi [@lostrouter]: https://github.com/lostrouter [@ryan-roemer]: https://github.com/ryan-roemer [@seanchas116]: https://github.com/seanchas116 [@tanem]: https://github.com/tanem [@vlkosinov]: https://github.com/vlkosinov webpack-stats-plugin-0.1.5/LICENSE.txt000066400000000000000000000020511306744432100174060ustar00rootroot00000000000000Copyright (C) 2015 Formidable Labs, Inc. 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. webpack-stats-plugin-0.1.5/README.md000066400000000000000000000074061306744432100170530ustar00rootroot00000000000000Webpack Stats Plugin ==================== [![Build Status][trav_img]][trav_site] This plugin will ingest the webpack [stats](https://github.com/webpack/docs/wiki/node.js-api#stats) object, process / transform the object and write out to a file for further consumption. The most common use case is building a hashed bundle and wanting to programmatically refer to the correct bundle path in your Node.js server. ## Installation The plugin is available via [npm](https://www.npmjs.com/package/webpack-stats-plugin): ``` $ npm install --save webpack-stats-plugin ``` ## Examples You can see lots of examples at [`demo/webpack.config.js`](demo/webpack.config.js). ### Basic ```js var StatsWriterPlugin = require("webpack-stats-plugin").StatsWriterPlugin; module.exports = { plugins: [ // Everything else **first**. // Write out stats file to build directory. new StatsWriterPlugin({ filename: "stats.json" // Default }) ] } ``` ### Custom Transform Function The transform function has a signature of: ```js /** * Transform skeleton. * * @param {Object} data Stats object * @param {Object} opts Options * @param {Object} opts.compiler Current compiler instance * @returns {String} String to emit to file */ function (data, opts) {} ``` which you can use like: ```js var StatsWriterPlugin = require("webpack-stats-plugin").StatsWriterPlugin; module.exports = { plugins: [ new StatsWriterPlugin({ transform: function (data, opts) { return JSON.stringify({ main: data.assetsByChunkName.main[0], css: data.assetsByChunkName.main[1] }, null, 2); } }) ] } ``` ## Plugins * [`StatsWriterPlugin(opts)`](#statswriterplugin-opts-) ### `StatsWriterPlugin(opts)` * **opts** (`Object`) options * **opts.filename** (`String`) output file name (Default: "stat.json") * **opts.fields** (`Array`) fields of stats obj to keep (Default: \["assetsByChunkName"\]) * **opts.transform** (`Function`) transform stats obj (Default: `JSON.stringify()`) Stats writer module. Stats can be a string or array (we"ll have array from using source maps): ```js "assetsByChunkName": { "main": [ "cd6371d4131fbfbefaa7.bundle.js", "../js-map/cd6371d4131fbfbefaa7.bundle.js.map" ] }, ``` **Note**: The 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. See: - http://webpack.github.io/docs/long-term-caching.html#get-filenames-from-stats - https://github.com/webpack/docs/wiki/node.js-api#stats **`filename`**: The `opts.filename` option can be a file name or path relative to `output.path` in webpack configuration. It should not be absolute. **`transform`**: By default, the retrieved stats object is `JSON.stringify`'ed but by supplying an alternate transform you can target _any_ output format. See [`demo/webpack.config.js`](demo/webpack.config.js) for various examples including Markdown output. - **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. ## Contributions Contributions welcome! Make sure to pass `$ gulp check`. [trav]: https://travis-ci.org/ [trav_img]: https://api.travis-ci.org/FormidableLabs/webpack-stats-plugin.svg [trav_site]: https://travis-ci.org/FormidableLabs/webpack-stats-plugin webpack-stats-plugin-0.1.5/demo/000077500000000000000000000000001306744432100165115ustar00rootroot00000000000000webpack-stats-plugin-0.1.5/demo/main.js000066400000000000000000000001601306744432100177700ustar00rootroot00000000000000/** * A demo file. */ /*eslint-disable no-console*/ console.log("Hello World!"); /*eslint-enable no-console*/ webpack-stats-plugin-0.1.5/demo/webpack.config.js000066400000000000000000000026431306744432100217340ustar00rootroot00000000000000/** * Webpack configuration */ var path = require("path"); var StatsWriterPlugin = require("../index").StatsWriterPlugin; module.exports = { cache: true, context: __dirname, entry: "./main.js", output: { path: path.join(__dirname, "build"), filename: "[hash].main.js" }, plugins: [ // Try various defaults and options. new StatsWriterPlugin(), new StatsWriterPlugin({}), new StatsWriterPlugin({ filename: "stats-transform.json", fields: null, transform: function (data) { return JSON.stringify(data.assetsByChunkName, null, 2); } }), new StatsWriterPlugin({ filename: "stats-transform.md", fields: null, transform: function (data) { var assetsByChunkName = data.assetsByChunkName; return Object.keys(assetsByChunkName).reduce(function (acc, key) { return acc += key + " | " + assetsByChunkName[key] + "\n"; }, "Name | Asset\n:--- | :----\n"); } }), new StatsWriterPlugin({ filename: "stats-transform-custom-obj.json", transform: function (data) { return JSON.stringify({ main: data.assetsByChunkName.main }, null, 2); } }), new StatsWriterPlugin({ filename: "stats-custom.json" }), // Relative paths work, but absolute paths do not currently. new StatsWriterPlugin({ filename: "../build2/stats-custom2.json" }) ] }; webpack-stats-plugin-0.1.5/gulpfile.js000066400000000000000000000036011306744432100177320ustar00rootroot00000000000000/** * Gulpfile */ var gulp = require("gulp"); var eslint = require("gulp-eslint"); var jscs = require("gulp-jscs"); var mdox = require("gulp-mdox"); // ---------------------------------------------------------------------------- // Constants // ---------------------------------------------------------------------------- var JS_FILES = [ "lib/**/*.js", "demo/*.js", "*.js" ]; // ---------------------------------------------------------------------------- // EsLint // ---------------------------------------------------------------------------- gulp.task("eslint", function () { return gulp .src(JS_FILES) .pipe(eslint()) .pipe(eslint.formatEach("stylish", process.stderr)) .pipe(eslint.failOnError()); }); // ---------------------------------------------------------------------------- // JsCs // ---------------------------------------------------------------------------- gulp.task("jscs", function () { return gulp .src(JS_FILES) .pipe(jscs()); }); // ---------------------------------------------------------------------------- // Quality // ---------------------------------------------------------------------------- gulp.task("check", ["jscs", "eslint"]); gulp.task("check:ci", ["jscs", "eslint"]); gulp.task("check:all", ["jscs", "eslint"]); // ---------------------------------------------------------------------------- // Docs // ---------------------------------------------------------------------------- gulp.task("docs", function () { return gulp .src([ "lib/**/*.js" ]) .pipe(mdox({ src: "./README.md", name: "README.md", start: "## Plugins", end: "## Contributions" })) .pipe(gulp.dest("./")); }); // ---------------------------------------------------------------------------- // Aggregations // ---------------------------------------------------------------------------- gulp.task("default", ["check"]); webpack-stats-plugin-0.1.5/index.js000066400000000000000000000001201306744432100172230ustar00rootroot00000000000000module.exports = { StatsWriterPlugin: require("./lib/stats-writer-plugin") }; webpack-stats-plugin-0.1.5/lib/000077500000000000000000000000001306744432100163335ustar00rootroot00000000000000webpack-stats-plugin-0.1.5/lib/stats-writer-plugin.js000066400000000000000000000061661306744432100226460ustar00rootroot00000000000000/** * Stats writer module. * * Stats can be a string or array (we"ll have array from using source maps): * * ```js * "assetsByChunkName": { * "main": [ * "cd6371d4131fbfbefaa7.bundle.js", * "../js-map/cd6371d4131fbfbefaa7.bundle.js.map" * ] * }, * ``` * * **Note**: The 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. * * See: * - http://webpack.github.io/docs/long-term-caching.html#get-filenames-from-stats * - https://github.com/webpack/docs/wiki/node.js-api#stats * * **`filename`**: The `opts.filename` option can be a file name or path relative to * `output.path` in webpack configuration. It should not be absolute. * * **`transform`**: By default, the retrieved stats object is `JSON.stringify`'ed * but by supplying an alternate transform you can target _any_ output format. * See [`demo/webpack.config.js`](demo/webpack.config.js) for various examples * including Markdown output. * * - **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). Just adding a simple * `JSON.stringify()` around your object is usually what you need to solve * any problems. * * @param {Object} opts options * @param {String} opts.filename output file name (Default: "stat.json") * @param {Array} opts.fields fields of stats obj to keep (Default: \["assetsByChunkName"\]) * @param {Function} opts.transform transform stats obj (Default: `JSON.stringify()`) * * @api public */ function StatsWriterPlugin(opts) { opts = opts || {}; this.opts = {}; this.opts.filename = opts.filename || "stats.json"; this.opts.fields = typeof opts.fields !== "undefined" ? opts.fields : ["assetsByChunkName"]; this.opts.transform = opts.transform || function (data) { return JSON.stringify(data, null, 2); }; } StatsWriterPlugin.prototype = { constructor: StatsWriterPlugin, apply: function (compiler) { var self = this; compiler.plugin("emit", function (curCompiler, callback) { // Get stats. // **Note**: In future, could pass something like `{ showAssets: true }` // to the `getStats()` function for more limited object returned. var stats = curCompiler.getStats().toJson(); // Filter to fields. if (self.opts.fields) { stats = self.opts.fields.reduce(function (memo, key) { memo[key] = stats[key]; return memo; }, {}); } // Transform to string. var statsStr = self.opts.transform(stats, { compiler: curCompiler }); curCompiler.assets[self.opts.filename] = { source: function () { return statsStr; }, size: function () { return statsStr.length; } }; callback(); }); } }; module.exports = StatsWriterPlugin; webpack-stats-plugin-0.1.5/package.json000066400000000000000000000014721306744432100200570ustar00rootroot00000000000000{ "name": "webpack-stats-plugin", "version": "0.1.5", "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", "webpack": "1.6.0" }, "repository": { "type": "git", "url": "https://github.com/FormidableLabs/webpack-stats-plugin" }, "keywords": [ "webpack" ], "author": "Ryan Roemer ", "license": "MIT", "bugs": { "url": "https://github.com/FormidableLabs/webpack-stats-plugin/issues" }, "files": [ "lib", "index.js" ], "scripts": { "test": "gulp check", "clean": "rm -rf demo/stats.json demo/build*", "build-demo": "npm run clean && cd demo && webpack" } }