Skip to content

Commit 3dff600

Browse files
committed
Update README
1 parent 7d8482d commit 3dff600

File tree

1 file changed

+91
-2
lines changed

1 file changed

+91
-2
lines changed

README.md

Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,97 @@
22

33
[![Build Status](https://travis-ci.org/geowarin/friendly-errors-webpack-plugin.svg?branch=master)](https://travis-ci.org/geowarin/friendly-errors-webpack-plugin)
44

5-
Not ready yet. See [this](https://github.com/facebookincubator/create-react-app/issues/401)
6-
and [this](https://github.com/geowarin/tarec/pull/16) for more context.
5+
Friendly-errors-webpack-plugin recognizes certain classes of webpack
6+
errors and cleans, aggregates and prioritizes them to provide a better
7+
Developer Experience.
8+
9+
It is easy to add types of errors so if you would like to see more
10+
errors get handled, please open a [PR](https://help.github.com/articles/creating-a-pull-request/)!
11+
12+
## Demo
13+
14+
### Build success
15+
16+
![success](http://i.imgur.com/MkUEhYz.gif)
17+
18+
### eslint-loader errors
19+
20+
![lint](http://i.imgur.com/xYRkldr.gif)
21+
22+
### babel-loader syntax errors
23+
24+
![babel](http://i.imgur.com/W59z8WF.gif)
25+
26+
### Module not found
27+
28+
![babel](http://i.imgur.com/OivW4As.gif)
29+
30+
## Options
31+
32+
You can pass options to the plugin:
33+
34+
```js
35+
new FriendlyErrorsPlugin({
36+
compilationSuccessInfo: {
37+
messages: ['You application is running here http://localhost:3000'],
38+
notes: ['Some additionnal notes to be displayed unpon successful compilation']
39+
},
40+
onErrors: function (severity, errors) {
41+
// You can listen to errors transformed and prioritized by the plugin
42+
// sevrity can be 'error' or 'warning'
43+
},
44+
// should the console be cleared between each compilation?
45+
// default is true
46+
shouldClearConsole: true,
47+
48+
// add formatters and transformers (see below)
49+
additionalFormatters: [],
50+
additionalTransformers: []
51+
})
52+
```
53+
54+
## Adding desktop notifications
55+
56+
The plugin has no native support for desktop notifications but it is easy
57+
to add them thanks to [node-notifier](https://www.npmjs.com/package/node-notifier) for instance.
58+
59+
```js
60+
var NotifierPlugin = require('friendly-errors-webpack-plugin');
61+
var notifier = require('node-notifier');
62+
var ICON = path.join(__dirname, 'icon.png');
63+
64+
new NotifierPlugin({
65+
onErrors: (severity, errors) => {
66+
if (severity !== 'error') {
67+
return;
68+
}
69+
const error = errors[0];
70+
notifier.notify({
71+
title: context.pkg.name,
72+
message: severity + ': ' + error.name,
73+
subtitle: error.file || '',
74+
icon: ICON
75+
});
76+
}
77+
})
78+
]
79+
```
80+
81+
## API
82+
83+
### Transformers and formatters
84+
85+
Webpack's errors processing, is done in four phases:
86+
87+
1. Extract relevant info from webpack errors. This is done by the plugin [here](https://github.com/geowarin/friendly-errors-webpack-plugin/blob/master/src/core/extractWebpackError.js)
88+
2. Apply transformers to all errors to identify and annotate well know errors and give them a priority
89+
3. Get only top priority error or top priority warnings if no errors are thrown
90+
4. Apply formatters to all annotated errors
91+
92+
You can add transformers and formatters. Please see [transformErrors](https://github.com/geowarin/friendly-errors-webpack-plugin/blob/master/src/core/transformErrors.js),
93+
and [formatErrors](https://github.com/geowarin/friendly-errors-webpack-plugin/blob/master/src/core/formatErrors.js)
94+
in the source code and take a look a the [default transformers](https://github.com/geowarin/friendly-errors-webpack-plugin/tree/master/src/transformers)
95+
and the [default formatters](https://github.com/geowarin/friendly-errors-webpack-plugin/tree/master/src/formatters).
796

897
## TODO
998

0 commit comments

Comments
 (0)