WIP - add extractor, generate snippet_data
This commit is contained in:
52
node_modules/webpack-stats-plugin/HISTORY.md
generated
vendored
Normal file
52
node_modules/webpack-stats-plugin/HISTORY.md
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
History
|
||||
=======
|
||||
|
||||
## 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
|
||||
19
node_modules/webpack-stats-plugin/LICENSE.txt
generated
vendored
Normal file
19
node_modules/webpack-stats-plugin/LICENSE.txt
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (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.
|
||||
131
node_modules/webpack-stats-plugin/README.md
generated
vendored
Normal file
131
node_modules/webpack-stats-plugin/README.md
generated
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
Webpack 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
|
||||
3
node_modules/webpack-stats-plugin/index.js
generated
vendored
Normal file
3
node_modules/webpack-stats-plugin/index.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
StatsWriterPlugin: require("./lib/stats-writer-plugin")
|
||||
};
|
||||
92
node_modules/webpack-stats-plugin/lib/stats-writer-plugin.js
generated
vendored
Normal file
92
node_modules/webpack-stats-plugin/lib/stats-writer-plugin.js
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
/**
|
||||
* 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;
|
||||
64
node_modules/webpack-stats-plugin/package.json
generated
vendored
Normal file
64
node_modules/webpack-stats-plugin/package.json
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
{
|
||||
"_from": "webpack-stats-plugin@^0.1.5",
|
||||
"_id": "webpack-stats-plugin@0.1.5",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-KeXxLr/VMVjTHWVqETrB97hhedk=",
|
||||
"_location": "/webpack-stats-plugin",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "webpack-stats-plugin@^0.1.5",
|
||||
"name": "webpack-stats-plugin",
|
||||
"escapedName": "webpack-stats-plugin",
|
||||
"rawSpec": "^0.1.5",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.1.5"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/gatsby"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/webpack-stats-plugin/-/webpack-stats-plugin-0.1.5.tgz",
|
||||
"_shasum": "29e5f12ebfd53158d31d656a113ac1f7b86179d9",
|
||||
"_spec": "webpack-stats-plugin@^0.1.5",
|
||||
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/gatsby",
|
||||
"author": {
|
||||
"name": "Ryan Roemer",
|
||||
"email": "ryan.roemer@formidablelabs.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/FormidableLabs/webpack-stats-plugin/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "Webpack stats plugin",
|
||||
"devDependencies": {
|
||||
"gulp": "3.8.10",
|
||||
"gulp-eslint": "0.2.2",
|
||||
"gulp-jscs": "1.4.0",
|
||||
"gulp-mdox": "0.0.2",
|
||||
"webpack": "1.6.0"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/FormidableLabs/webpack-stats-plugin#readme",
|
||||
"keywords": [
|
||||
"webpack"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "webpack-stats-plugin.js",
|
||||
"name": "webpack-stats-plugin",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/FormidableLabs/webpack-stats-plugin.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build-demo": "npm run clean && cd demo && webpack",
|
||||
"clean": "rm -rf demo/stats.json demo/build*",
|
||||
"test": "gulp check"
|
||||
},
|
||||
"version": "0.1.5"
|
||||
}
|
||||
Reference in New Issue
Block a user