UNPKG

4.17 kBMarkdownView Raw
1[![Standard JS][standard-js-src]][standard-js-href]
2[![npm version][npm-version-src]][npm-version-href]
3[![npm downloads][npm-downloads-src]][npm-downloads-href]
4[![package phobia][package-phobia-src]][package-phobia-href]
5
6
7<div align="center">
8 <!-- replace with accurate logo e.g from https://worldvectorlogo.com/ -->
9 <img width="200" height="200" hspace="25" src="./assets/logo.svg">
10 <a href="https://webpack.js.org/">
11 <img width="200" height="200" hspace="25" src="https://cdn.rawgit.com/webpack/media/e7485eb2/logo/icon-square-big.svg">
12 </a>
13 <p>Elegant ProgressBar and Profiler for Webpack</p>
14</div>
15
16✔ Display elegant progress bar while building or watch
17
18✔ Support of multiple concurrent builds (useful for SSR)
19
20✔ Pretty print filename and loaders
21
22✔ Windows compatible
23
24**Fully** customizable using reporters
25
26✔ Advanced build profiler
27
28<div align="center">
29<br>
30<img src="./assets/screen1.png" width="600px">
31<p>Multi progress bars</p>
32<br>
33</div>
34
35<div align="center">
36<br>
37<img src="./assets/screen2.png" width="600px">
38<p>Build Profiler</p>
39<br>
40</div>
41
42<h2 align="center">Getting Started</h2>
43
44To begin, you'll need to install `webpackbar`:
45
46Using npm:
47
48```bash
49npm install webpackbar -D
50```
51
52Using yarn:
53
54```bash
55yarn add webpackbar -D
56```
57
58Then add the reporter as a plugin to your webpack config.
59
60**webpack.config.js**
61
62```js
63const webpack = require('webpack');
64const WebpackBar = require('webpackbar');
65
66module.exports = {
67 context: path.resolve(__dirname),
68 devtool: 'source-map',
69 entry: './entry.js',
70 output: {
71 filename: './output.js',
72 path: path.resolve(__dirname)
73 },
74 plugins: [
75 new WebpackBar()
76 ]
77};
78```
79
80<h2 align="center">Options</h2>
81
82### `name`
83 - Default: `webpack`
84
85Name.
86
87### `color`
88 - Default: `green`
89
90Primary color (can be HEX like `#xxyyzz` or a web color like `green`).
91
92### `profile`
93 - Default: `false`
94
95Enable profiler.
96
97### `fancy`
98
99 - Default: `true` when not in CI or testing mode.
100
101Enable bars reporter.
102
103### `basic`
104
105 - Default: `true` when running in minimal environments.
106
107Enable a simple log reporter (only start and end).
108
109### `reporter`
110
111Register a custom reporter.
112
113### `reporters`
114 - Default: `[]`
115
116Register an Array of your custom reporters. (Same as `reporter` but array)
117
118<h2 align="center">Custom Reporters</h2>
119
120Webpackbar comes with a fancy progress-bar out of the box.
121But you may want to show progress somewhere else or provide your own.
122
123For this purpose, you can provide one or more extra reporters using `reporter` and `reporters` options.
124
125**NOTE:** If you plan to provide your own reporter, don't forget to setting `fancy` and `basic` options to false to prevent conflicts.
126
127A reporter should be instance of a class or plain object and functions for special hooks. It is not necessary to implement all functions, webpackbar only calls those that exists.
128
129**Simple logger:**
130
131```js
132{
133 start(context) {
134 // Called when (re)compile is started
135 },
136 change(context) {
137 // Called when a file changed on watch mode
138 },
139 update(context) {
140 // Called after each progress update
141 },
142 done(context) {
143 // Called when compile finished
144 },
145 progress(context) {
146 // Called when build progress updated
147 },
148 allDone(context) {
149 // Called when _all_ compiles finished
150 },
151 beforeAllDone(context) {
152 },
153 afterAllDone(context) {
154 },
155}
156```
157
158`context` is the reference to the plugin. You can use `context.state` to access status.
159
160
161**Schema of `context.state`:**
162
163```js
164{
165 start,
166 progress,
167 message,
168 details,
169 request,
170 hasErrors
171}
172```
173
174<h2 align="center">License</h2>
175
176MIT - Made with 💖 By Nuxt.js team!
177
178<!-- Refs -->
179[standard-js-src]: https://flat.badgen.net/badge/code%20style/standard/green
180[standard-js-href]: https://standardjs.com
181
182[npm-version-src]: https://flat.badgen.net/npm/v/webpackbar/latest
183[npm-version-href]: https://npmjs.com/package/webpackbar
184
185[npm-downloads-src]: https://flat.badgen.net/npm/dt/webpackbar
186[npm-downloads-href]: https://npmjs.com/package/webpackbar
187
188[package-phobia-src]: https://flat.badgen.net/packagephobia/install/webpackbar
189[package-phobia-href]: https://packagephobia.now.sh/result?p=webpackbar