Skip to content
This repository was archived by the owner on Jul 27, 2021. It is now read-only.

Commit fe2005c

Browse files
authored
Merge pull request #4 from rogeliog/patch-1
Add getting started to README
2 parents 58693b3 + 3f0bbc7 commit fe2005c

File tree

1 file changed

+47
-2
lines changed

1 file changed

+47
-2
lines changed

README.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,51 @@ Developer Experience.
1010
It is easy to add types of errors so if you would like to see more
1111
errors get handled, please open a [PR](https://help.github.com/articles/creating-a-pull-request/)!
1212

13+
## Getting started
14+
15+
### Installation
16+
17+
```bash
18+
npm install friendly-errors-webpack-plugin --save-dev
19+
```
20+
21+
### Basic usage
22+
23+
Simply add `FriendlyErrorsWebpackPlugin` to the plugin section in your Webpack config.
24+
25+
```javascript
26+
var FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
27+
28+
var webpackConfig = {
29+
// ...
30+
plugins: [
31+
new FriendlyErrorsWebpackPlugin(),
32+
],
33+
// ...
34+
}
35+
```
36+
37+
### Turn off errors
38+
39+
You need to turn off all error logging by setting your webpack config quiet option to true.
40+
41+
```javascript
42+
app.use(require('webpack-dev-middleware')(compiler, {
43+
quiet: true,
44+
publicPath: config.output.publicPath,
45+
}));
46+
```
47+
48+
If you use webpack-hot-middleware, that is done by setting the log option to a no-op. You can do something sort of like this, depending upon your setup:
49+
50+
```javascript
51+
app.use(require('webpack-hot-middleware')(compiler, {
52+
log: () => {}
53+
}));
54+
```
55+
56+
_Thanks to [webpack-dashboard](https://github.com/FormidableLabs/webpack-dashboard) for this piece of info._
57+
1358
## Demo
1459

1560
### Build success
@@ -45,7 +90,7 @@ new FriendlyErrorsPlugin({
4590
// should the console be cleared between each compilation?
4691
// default is true
4792
shouldClearConsole: true,
48-
93+
4994
// add formatters and transformers (see below)
5095
additionalFormatters: [],
5196
additionalTransformers: []
@@ -84,7 +129,7 @@ new NotifierPlugin({
84129
### Transformers and formatters
85130

86131
Webpack's errors processing, is done in four phases:
87-
132+
88133
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)
89134
2. Apply transformers to all errors to identify and annotate well know errors and give them a priority
90135
3. Get only top priority error or top priority warnings if no errors are thrown

0 commit comments

Comments
 (0)