Skip to content

Commit 147392d

Browse files
michael-ciniawskyjoshwiens
authored andcommitted
docs(README): standardize (#72)
1 parent 095fa88 commit 147392d

File tree

1 file changed

+137
-51
lines changed

1 file changed

+137
-51
lines changed

README.md

Lines changed: 137 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
[![npm][npm]][npm-url]
2+
[![node][node]][node-url]
23
[![deps][deps]][deps-url]
4+
[![test][test]][test-url]
5+
[![coverage][cover]][cover-url]
36
[![chat][chat]][chat-url]
47

58
<div align="center">
6-
<!-- replace with accurate logo e.g from https://worldvectorlogo.com/ -->
79
<a href="https://github.com/webpack/webpack">
8-
<img width="200" height="200" vspace="" hspace="25"
10+
<img width="200" height="200"
911
src="https://cdn.rawgit.com/webpack/media/e7485eb2/logo/icon.svg">
1012
</a>
1113
<h1>Compression Plugin</h1>
12-
<p>Prepare compressed versions of assets to serve them with Content-Encoding.<p>
14+
<p>Prepare compressed versions of assets to serve them with Content-Encoding<p>
1315
</div>
1416

1517
<h2 align="center">Install</h2>
@@ -20,78 +22,162 @@ npm i -D compression-webpack-plugin
2022

2123
<h2 align="center">Usage</h2>
2224

23-
``` javascript
24-
var CompressionPlugin = require("compression-webpack-plugin");
25+
**webpack.config.js**
26+
```js
27+
const CompressionPlugin = require("compression-webpack-plugin")
28+
2529
module.exports = {
26-
plugins: [
27-
new CompressionPlugin({
28-
asset: "[path].gz[query]",
29-
algorithm: "gzip",
30-
test: /\.(js|html)$/,
31-
threshold: 10240,
32-
minRatio: 0.8
33-
})
34-
]
30+
plugins: [
31+
new CompressionPlugin(...options)
32+
]
3533
}
3634
```
3735

38-
Arguments:
36+
<h2 align="center">Options</h2>
37+
38+
|Name|Type|Default|Description|
39+
|:--:|:--:|:-----:|:----------|
40+
|**`test`**|`{RegExp}`|`.`|All assets matching this `{RegExp}` are processed|
41+
|**`asset`**|`{String}`|`[path].gz[query]`|The target asset name. `[file]` is replaced with the original asset. `[path]` is replaced with the path of the original asset and `[query]` with the query|
42+
|**`filename`**|`{Function}`|`false`|A `{Function}` `(asset) => asset` which receives the asset name (after processing `asset` option) and returns the new asset name|
43+
|**`algorithm`**|`{String\|Function}`|`gzip`|Can be `(buffer, cb) => cb(buffer)` or if a {String}` is used the algorithm is taken from `zlib`|
44+
|**`threshold`**|`{Number}`|`0`|Only assets bigger than this size are processed. In bytes.|
45+
|**`minRatio`**|`{Number}`|`0.8`|Only assets that compress better that this ratio are processed|
46+
|**`deleteOriginalAssets`**|`{Boolean}`|`false`|Whether to delete the original assets or not|
3947

40-
* `asset`: The target asset name. `[file]` is replaced with the original asset. `[path]` is replaced with the path of the original asset and `[query]` with the query. Defaults to `"[path].gz[query]"`.
41-
* `filename`: A `function(asset)` which receives the asset name (after processing `asset` option) and returns the new asset name. Defaults to `false`.
42-
* `algorithm`: Can be a `function(buf, callback)` or a string. For a string the algorithm is taken from `zlib` (or zopfli for `zopfli`). Defaults to `"gzip"`.
43-
* `test`: All assets matching this RegExp are processed. Defaults to every asset.
44-
* `threshold`: Only assets bigger than this size are processed. In bytes. Defaults to `0`.
45-
* `minRatio`: Only assets that compress better that this ratio are processed. Defaults to `0.8`.
46-
* `deleteOriginalAssets`: Whether to delete the original assets or not. Defaults to `false`.
4748

48-
Option Arguments for Zopfli (see [node-zopfli](https://github.com/pierreinglebert/node-zopfli#options) doc for details):
49-
* verbose: Default: false,
50-
* verbose_more: Default: false,
51-
* numiterations: Default: 15,
52-
* blocksplitting: Default: true,
53-
* blocksplittinglast: Default: false,
54-
* blocksplittingmax: Default: 15
49+
### `test`
50+
51+
**webpack.config.js**
52+
```js
53+
[
54+
new CompressionPlugin({
55+
test: /\.js/
56+
})
57+
]
58+
```
59+
60+
### `asset`
61+
62+
**webpack.config.js**
63+
```js
64+
[
65+
new CompressionPlugin({
66+
asset: '[path].gz[query]'
67+
})
68+
]
69+
```
70+
71+
### `filename`
72+
73+
**webpack.config.js**
74+
```js
75+
[
76+
new CompressionPlugin({
77+
filename (asset) {
78+
asset = 'rename'
79+
return asset
80+
}
81+
})
82+
]
83+
```
84+
85+
### `algorithm`
86+
87+
**webpack.config.js**
88+
```js
89+
[
90+
new CompressionPlugin({
91+
algorithm: 'gzip'
92+
})
93+
]
94+
```
95+
96+
### `threshold`
97+
98+
**webpack.config.js**
99+
```js
100+
[
101+
new CompressionPlugin({
102+
threshold: 0
103+
})
104+
]
105+
```
106+
107+
### `minRatio`
108+
109+
**webpack.config.js**
110+
```js
111+
[
112+
new CompressionPlugin({
113+
minRatio: 0.8
114+
})
115+
]
116+
```
117+
118+
### `deleteOriginalAssets`
119+
120+
**webpack.config.js**
121+
```js
122+
[
123+
new CompressionPlugin({
124+
deleteOriginalAssets: true
125+
})
126+
]
127+
```
55128

56129
<h2 align="center">Maintainers</h2>
57130

58131
<table>
59132
<tbody>
60-
<tr>
61-
<td align="center">
62-
<img width="150" height="150"
63-
src="https://avatars3.githubusercontent.com/u/166921?v=3&s=150">
133+
<tr>
134+
<td align="center">
135+
<a href="https://github.com/d3viant0ne">
136+
<img width="150" height="150" src="https://github.com/d3viant0ne.png?v=3&s=150">
64137
</br>
65-
<a href="https://github.com/bebraw">Juho Vepsäläinen</a>
66-
</td>
67-
<td align="center">
68-
<img width="150" height="150"
69-
src="https://avatars2.githubusercontent.com/u/8420490?v=3&s=150">
138+
Joshua Wiens
139+
</a>
140+
</td>
141+
<td align="center">
142+
<a href="https://github.com/bebraw">
143+
<img width="150" height="150" src="https://github.com/bebraw.png?v=3&s=150">
70144
</br>
71-
<a href="https://github.com/d3viant0ne">Joshua Wiens</a>
72-
</td>
73-
<td align="center">
74-
<img width="150" height="150"
75-
src="https://avatars3.githubusercontent.com/u/533616?v=3&s=150">
145+
Juho Vepsäläinen
146+
</a>
147+
</td>
148+
<td align="center">
149+
<a href="https://github.com/michael-ciniawsky">
150+
<img width="150" height="150" src="https://github.com/michael-ciniawsky.png?v=3&s=150">
76151
</br>
77-
<a href="https://github.com/SpaceK33z">Kees Kluskens</a>
78-
</td>
79-
<td align="center">
80-
<img width="150" height="150"
81-
src="https://avatars3.githubusercontent.com/u/3408176?v=3&s=150">
152+
Michael Ciniawsky
153+
</a>
154+
</td>
155+
<td align="center">
156+
<a href="https://github.com/evilebottnawi">
157+
<img width="150" height="150" src="https://github.com/evilebottnawi.png?v=3&s=150">
82158
</br>
83-
<a href="https://github.com/TheLarkInn">Sean Larkin</a>
84-
</td>
85-
</tr>
159+
Alexander Krasnoyarov
160+
</a>
161+
</td>
162+
</tr>
86163
<tbody>
87164
</table>
88165

89166

90167
[npm]: https://img.shields.io/npm/v/compression-webpack-plugin.svg
91168
[npm-url]: https://npmjs.com/package/compression-webpack-plugin
92169

170+
[node]: https://img.shields.io/node/v/compression-webpack-plugin.svg
171+
[node-url]: https://nodejs.org
172+
93173
[deps]: https://david-dm.org/webpack-contrib/compression-webpack-plugin.svg
94174
[deps-url]: https://david-dm.org/webpack-contrib/compression-webpack-plugin
95175

176+
[test]: https://secure.travis-ci.org/webpack-contrib/compression-webpack-plugin.svg
177+
[test-url]: http://travis-ci.org/webpack-contrib/compression-webpack-plugin
178+
179+
[cover]: https://codecov.io/gh/webpack-contrib/compression-webpack-plugin/branch/master/graph/badge.svg
180+
[cover-url]: https://codecov.io/gh/webpack-contrib/compression-webpack-plugin
181+
96182
[chat]: https://img.shields.io/badge/gitter-webpack%2Fwebpack-brightgreen.svg
97183
[chat-url]: https://gitter.im/webpack/webpack

0 commit comments

Comments
 (0)