Skip to content

Commit

Permalink
chore: tweak readme docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed Jul 21, 2021
1 parent 091ec29 commit e7b1e90
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ $ npm install webpack-format-messages --save-dev
```js
const webpack = require('webpack');
const formatMessages = require('webpack-format-messages');
// or
const { formatMessages } = require('webpack-format-messages');

const compiler = webpack(/* config */);

Expand All @@ -53,24 +55,34 @@ compiler.hooks.done.tap('done', (stats) => {
if (messages.warnings.length) {
console.log('Compiled with warnings.');
messages.warnings.forEach(w => console.log(w));
}
}
});
```


## API

### formatMessages(input)
### formatMessages(stats)
Returns: `{ errors: string[], warnings: string[] }`

Extracts & prettifies warning and error messages from Webpack.

#### input
> **Note:** This is also the `default` export.
#### stats

Type: `Object`

A Webpack [`stats`](https://github.com/webpack/docs/wiki/node.js-api#stats) object.


### formatMessage(message)
Returns: `string`

Transforms an individual webpack `stats` message object into a string.

> **Note:** You probably don't want to use this directly! It's used by `formatMessages` for you.
## Related

* [`webpack-messages`](https://github.com/lukeed/webpack-messages) -- Wraps this module as a Webpack plugin, with lifecycle hooks
Expand Down

0 comments on commit e7b1e90

Please sign in to comment.