UNPKG

3.71 kBMarkdownView Raw
1<div align="center">
2 <a href="https://github.com/webpack/webpack">
3 <img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg">
4 </a>
5</div>
6
7[![npm][npm]][npm-url]
8[![node][node]][node-url]
9[![deps][deps]][deps-url]
10[![tests][tests]][tests-url]
11[![chat][chat]][chat-url]
12
13# webpack-stylish
14
15A stylish, opinionated reporter for webpack.
16
17![](assets/screenshot.png)
18
19Compared to the default output:
20
21![](assets/screenshot-original.png)
22
23Let's be honest, the default build output for webpack wouldn't exactly hang in
24the Louvre. Great tools should have beautiful output. This reporter is
25specifically structured to present common, important¹ information about a build
26in a visually pleasing and easy-to-read format and style.
27
28¹ _subjective, but based on shared experiences._
29
30## Getting Started
31
32To begin, you'll need to install `webpack-stylish`:
33
34```console
35$ npm install webpack-stylish --save-dev
36```
37
38Then add the reporter as a plugin to your `webpack` config. For example:
39
40```js
41const path = require('path');
42const webpack = require('webpack');
43const Stylish = require('webpack-stylish');
44
45module.exports = {
46 context: path.resolve(__dirname),
47 devtool: 'source-map',
48 entry: './entry.js',
49 output: {
50 filename: './output.js',
51 path: path.resolve(__dirname)
52 },
53 plugins: [
54 new webpack.NamedModulesPlugin(),
55 new Stylish()
56 ]
57};
58```
59
60### MultiCompilers
61
62If you use a config that consists of an array of configs (aka. `MultiCompiler`),
63we recommend using _a single instance_ of the reporter across all configs. eg;
64
65```js
66const StylishReporter = require('webpack-stylish');
67const stylish = new StylishReporter();
68
69module.exports = [
70 {
71 ...
72 plugins: [
73 new webpack.NamedModulesPlugin(),
74 stylish
75 ]
76 },
77 {
78 ...
79 plugins: [
80 new webpack.NamedModulesPlugin(),
81 stylish
82 ]
83 }
84];
85```
86
87Internally, the reporter will keep track of the compiler instances it's been
88added to and will display summary information for all compilers. If you _don't_
89use a single, shared instance of the reporter, you're going to see a lot of
90duplicate information, and that'd just be silly.
91
92### Webpack CLI
93
94Because `webpack-cli` reads the `stats` config property _before_ the compilation
95starts, it tends to go on doing it's own thing. When using `webpack-stylish` in
96a config that you're running via the CLI, you need to add `stats: 'none'` to the
97config. Otherwise you'll see both this reporter's output, **and** the CLI's.
98
99## Options
100
101There are none! If you're in need of fine-grained control of webpack's build
102information out, please don't use this reporter. Instead, you can fine-tune
103webpack's default output via the
104[`stats` config property](https://webpack.js.org/configuration/stats/#stats).
105
106## Gotchas
107
108The `webpack-stylish` reporter will _straight up ignore_ the `stats` property in
109your `webpack` config, if you have one set. _(This reporter is opinionated!)_.
110
111## Contributing
112
113We welcome your contributions! Please have a read of
114[CONTRIBUTING.md](CONTRIBUTING.md) for more information on how to get involved.
115
116## License
117
118#### [MIT](./LICENSE)
119
120[npm]: https://img.shields.io/npm/v/webpack-stylish.svg
121[npm-url]: https://npmjs.com/package/webpack-stylish
122
123[node]: https://img.shields.io/node/v/webpack-stylish.svg
124[node-url]: https://nodejs.org
125
126[deps]: https://david-dm.org/webpack-contrib/webpack-stylish.svg
127[deps-url]: https://david-dm.org/webpack-contrib/webpack-stylish
128
129[tests]: http://img.shields.io/travis/webpack-contrib/webpack-stylish.svg
130[tests-url]: https://travis-ci.org/webpack-contrib/webpack-stylish
131
132[chat]: https://badges.gitter.im/webpack/webpack.svg
133[chat-url]: https://gitter.im/webpack/webpack