Skip to content

Commit

Permalink
Merge pull request #1 from shifteee/master
Browse files Browse the repository at this point in the history
 upstream sync
  • Loading branch information
shifteee authored Mar 5, 2018
2 parents e76215a + b2cd050 commit 3176e8b
Show file tree
Hide file tree
Showing 36 changed files with 6,219 additions and 464 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
test/*/build*
235 changes: 9 additions & 226 deletions .eslintrc

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
\.project
bower_components
node_modules
npm-debug\.log
npm-debug.log*
yarn-error.log*

# Build
coverage
demo/stats.json
demo/build*
test/*/build*
!test/expected/build*
70 changes: 0 additions & 70 deletions .jscsrc

This file was deleted.

13 changes: 9 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
language: node_js

node_js:
- "0.10"
- "0.12"
- "4"
- "6"
- "8"
- "9"

sudo: false

branches:
only:
- master

script:
- node index.js
- node_modules/.bin/gulp check:ci
- npm run build-demo
- yarn run check
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
History
=======
## 0.2.0-regru

* **Breaking**: Update to node4+.
* Webpack4 compatibility.
(*[@jdelStrother][]*)

## 0.1.5-regru

* Stats is now always written to disk
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2015 Formidable Labs, Inc.
Copyright (C) 2015-2018 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
Expand Down
53 changes: 39 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@ programmatically refer to the correct bundle path in your Node.js server.
The plugin is available via [npm](https://www.npmjs.com/package/webpack-stats-plugin):

```
$ npm install --save webpack-stats-plugin
$ npm install --save-dev webpack-stats-plugin
$ yarn add --dev webpack-stats-plugin
```

## Examples

You can see lots of examples at
[`demo/webpack.config.js`](demo/webpack.config.js).
We have example webpack configurations for all versions of webpack. See., e.g.
[`test/webpack4/webpack.config.js`](test/webpack4/webpack.config.js).

### Basic

```js
var StatsWriterPlugin = require("webpack-stats-plugin").StatsWriterPlugin;
const StatsWriterPlugin = require("webpack-stats-plugin").StatsWriterPlugin;

module.exports = {
plugins: [
Expand Down Expand Up @@ -59,12 +60,12 @@ function (data, opts) {}
which you can use like:

```js
var StatsWriterPlugin = require("webpack-stats-plugin").StatsWriterPlugin;
const StatsWriterPlugin = require("webpack-stats-plugin").StatsWriterPlugin;

module.exports = {
plugins: [
new StatsWriterPlugin({
transform: function (data, opts) {
transform(data, opts) {
return JSON.stringify({
main: data.assetsByChunkName.main[0],
css: data.assetsByChunkName.main[1]
Expand Down Expand Up @@ -113,19 +114,43 @@ See:

**`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.
See [`test/webpack4/webpack.config.js`](test/webpack4/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.
- **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`.
Contributions welcome!

We test against all versions of webpack. For a full explanation of our
functional tests, see [test/README.md](test/README.md)

To get started, first install:

```sh
$ yarn
```

Our tests first do various webpack builds and then run mocha asserts on the real
outputted stats files. Inefficient, but for our small sample size efficient
enough.

```sh
# Lint and tests
$ yarn run lint
$ yarn run test

# All together
$ yarn run 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
[yarn workspaces]: https://yarnpkg.com/blog/2017/08/02/introducing-workspaces/
6 changes: 0 additions & 6 deletions demo/main.js

This file was deleted.

65 changes: 0 additions & 65 deletions gulpfile.js

This file was deleted.

6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"use strict";

const StatsWriterPlugin = require("./lib/stats-writer-plugin");

module.exports = {
StatsWriterPlugin: require("./lib/stats-writer-plugin")
StatsWriterPlugin
};
Loading

0 comments on commit 3176e8b

Please sign in to comment.