Skip to content

Commit dceace5

Browse files
docs(README): change style, add logos, badges, maintainers && LICENSE
1 parent 73ad568 commit dceace5

File tree

1 file changed

+166
-42
lines changed

1 file changed

+166
-42
lines changed

README.md

Lines changed: 166 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,137 @@
1-
# html loader for webpack
1+
[![npm][npm]][npm-url]
2+
[![deps][deps]][deps-url]
3+
[![test][test]][test-url]
4+
[![coverage][cover]][cover-url]
5+
[![chat][chat]][chat-url]
6+
7+
<div align="center">
8+
<img width="200" height="200"
9+
src="https://worldvectorlogo.com/logos/html5.svg">
10+
<a href="https://github.com/webpack/webpack">
11+
<img width="200" height="200" vspace="" hspace="25"
12+
src="https://worldvectorlogo.com/logos/webpack.svg">
13+
</a>
14+
<h1>HTML Loader</h1>
15+
<p>Exports HTML as string. HTML is minimized when the compiler demands.<p>
16+
</div>
17+
18+
<h2 align="center">Install</h2>
19+
20+
```bash
21+
npm i -D html-loader
22+
```
223

3-
Exports HTML as string. HTML is minimized when the compiler demands.
24+
<h2 align="center">Usage</h2>
425

5-
By default every local `<img src="image.png">` is required (`require("./image.png")`). You may need to specify loaders for images in your configuration (recommended `file-loader` or `url-loader`).
26+
By default every local `<img src="image.png">` is required (`require('./image.png')`). You may need to specify loaders for images in your configuration (recommended `file-loader` or `url-loader`).
627

728
You can specify which tag-attribute combination should be processed by this loader via the query parameter `attrs`. Pass an array or a space-separated list of `<tag>:<attribute>` combinations. (Default: `attrs=img:src`)
829

930
To completely disable tag-attribute processing (for instance, if you're handling image loading on the client side) you can pass in `attrs=false`.
1031

11-
## Usage
12-
13-
[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)
14-
15-
## Examples
32+
<h2 align="center">Examples</h2>
1633

1734
With this configuration:
1835

19-
``` javascript
36+
```js
2037
{
21-
module: { loaders: [
22-
{ test: /\.jpg$/, loader: "file-loader" },
23-
{ test: /\.png$/, loader: "url-loader?mimetype=image/png" }
24-
]},
38+
module: {
39+
loaders: [
40+
{ test: /\.jpg$/, loader: "file-loader" },
41+
{ test: /\.png$/, loader: "url-loader?mimetype=image/png" }
42+
]
43+
},
2544
output: {
2645
publicPath: "http://cdn.example.com/[hash]/"
2746
}
2847
}
2948
```
3049

3150
``` html
32-
<!-- fileA.html -->
33-
<img src="image.jpg" data-src="image2x.png" >
51+
<!-- file.html -->
52+
<img src="image.png" data-src="image2x.png" >
3453
```
3554

36-
``` javascript
37-
require("html!./fileA.html");
38-
// => '<img src="http://cdn.example.com/49e...ba9f/a9f...92ca.jpg" data-src="image2x.png" >'
55+
```js
56+
require("html!./file.html");
3957

58+
// => '<img src="http://cdn.example.com/49eba9f/a992ca.jpg"
59+
// data-src="image2x.png">'
60+
```
61+
62+
```js
4063
require("html?attrs=img:data-src!./file.html");
41-
// => '<img src="image.png" data-src="data:image/png;base64,..." >'
4264

65+
// => '<img src="image.png" data-src="data:image/png;base64,..." >'
66+
```
67+
68+
```js
4369
require("html?attrs=img:src img:data-src!./file.html");
4470
require("html?attrs[]=img:src&attrs[]=img:data-src!./file.html");
45-
// => '<img src="http://cdn.example.com/49e...ba9f/a9f...92ca.jpg" data-src="data:image/png;base64,..." >'
4671

72+
// => '<img src="http://cdn.example.com/49eba9f/a992ca.png"
73+
// data-src="data:image/png;base64,..." >'
74+
```
75+
76+
```js
4777
require("html?-attrs!./file.html");
78+
4879
// => '<img src="image.jpg" data-src="image2x.png" >'
80+
```
4981

50-
/// minimized by running `webpack --optimize-minimize`
51-
// => '<img src=http://cdn.example.com/49e...ba9f/a9f...92ca.jpg data-src=data:image/png;base64,...>'
82+
minimized by running `webpack --optimize-minimize`
5283

84+
```html
85+
'<img src=http://cdn.example.com/49eba9f/a9f92ca.jpg
86+
data-src=data:image/png;base64,...>'
5387
```
5488

55-
## 'Root-relative' urls
89+
### 'Root-relative' URLs
5690

5791
For urls that start with a `/`, the default behavior is to not translate them.
5892
If a `root` query parameter is set, however, it will be prepended to the url
5993
and then translated.
6094

61-
With the same configuration above:
95+
With the same configuration as above:
96+
6297
``` html
63-
<!-- fileB.html -->
98+
<!-- file.html -->
6499
<img src="/image.jpg">
65100
```
66101

67-
``` javascript
102+
```js
103+
require("html!./file.html");
68104

69-
require("html!./fileB.html");
70105
// => '<img src="/image.jpg">'
106+
```
71107

72-
require("html?root=.!./fileB.html");
73-
// => '<img src="http://cdn.example.com/49e...ba9f/a9f...92ca.jpg">'
108+
```js
109+
require("html?root=.!./file.html");
74110

111+
// => '<img src="http://cdn.example.com/49eba9f/a992ca.jpg">'
75112
```
76113

77-
## Interpolation
114+
### Interpolation
78115

79116
You can use `interpolate` flag to enable interpolation syntax for ES6 template strings, like so:
80117

81-
```
118+
```js
82119
require("html?interpolate!./file.html");
83120
```
84121

85-
```
86-
<img src="${require(`./images/gallery.png`)}" />
87-
<div>${require('./partials/gallery.html')}</div>
122+
```html
123+
<img src="${require(`./images/gallery.png`)}">
124+
125+
<div>${require('./components/gallery.html')}</div>
88126
```
89127

90-
## Advanced options
128+
### Advanced options
91129

92130
If you need to pass [more advanced options](https://github.com/webpack/html-loader/pull/46), especially those which cannot be stringified, you can also define an `htmlLoader`-property on your `webpack.config.js`:
93131

94-
``` javascript
95-
var path = require('path');
96-
...
132+
```js
133+
var path = require('path')
134+
97135
module.exports = {
98136
...
99137
module: {
@@ -114,7 +152,7 @@ module.exports = {
114152

115153
If you need to define two different loader configs, you can also change the config's property name via `html?config=otherHtmlLoaderConfig`:
116154

117-
```javascript
155+
```js
118156
module.exports = {
119157
...
120158
module: {
@@ -131,6 +169,92 @@ module.exports = {
131169
};
132170
```
133171

134-
## License
135-
136-
MIT (http://www.opensource.org/licenses/mit-license.php)
172+
<h2 align="center">Maintainers</h2>
173+
174+
<table>
175+
<tbody>
176+
<tr>
177+
<td align="center">
178+
<img width="150 height="150"
179+
src="https://avatars.githubusercontent.com/u/18315?v=3">
180+
<a href="https://github.com/hemanth">Hermanth</a>
181+
</td>
182+
<td align="center">
183+
<img width="150 height="150"
184+
src="https://avatars.githubusercontent.com/u/8420490?v=3">
185+
<a href="https://github.com/d3viant0ne">Joshua Wiens</a>
186+
</td>
187+
<td align="center">
188+
<img width="150" height="150" src="https://avatars.githubusercontent.com/u/5419992?v=3">
189+
<a href="https://github.com/michael-ciniawsky">Michael Ciniawsky</a>
190+
</td>
191+
<td align="center">
192+
<img width="150" height="150"
193+
src="https://avatars.githubusercontent.com/u/6542274?v=3">
194+
<a href="https://github.com/imvetri">Imvetri</a>
195+
</td>
196+
<tr>
197+
<tr>
198+
<td align="center">
199+
<img width="150" height="150"
200+
src="https://avatars.githubusercontent.com/u/1520965?v=3">
201+
<a href="https://github.com/andreicek">Andrei Crnković</a>
202+
</td>
203+
<td align="center">
204+
<img width="150" height="150"
205+
src="https://avatars.githubusercontent.com/u/3367801?v=3">
206+
<a href="https://github.com/abouthiroppy">Yuta Hiroto</a>
207+
</td>
208+
<td align="center">
209+
<img width="150" height="150" src="https://avatars.githubusercontent.com/u/80044?v=3">
210+
<a href="https://github.com/petrunov">Vesselin Petrunov</a>
211+
</td>
212+
<td align="center">
213+
<img width="150" height="150"
214+
src="https://avatars.githubusercontent.com/u/973543?v=3">
215+
<a href="https://github.com/gajus">Gajus Kuizinas</a>
216+
</td>
217+
<tr>
218+
<tbody>
219+
</table>
220+
221+
<h2 align="center">LICENSE</h2>
222+
223+
> MIT
224+
225+
> http://www.opensource.org/licenses/mit-license.php
226+
227+
> Copyright (c) 2016 Tobias Koppers @sokra
228+
229+
> Permission is hereby granted, free of charge, to any person obtaining a copy
230+
of this software and associated documentation files (the "Software"), to deal
231+
in the Software without restriction, including without limitation the rights
232+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
233+
copies of the Software, and to permit persons to whom the Software is
234+
furnished to do so, subject to the following conditions:
235+
236+
> The above copyright notice and this permission notice shall be included in all
237+
copies or substantial portions of the Software.
238+
239+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
240+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
241+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
242+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
243+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
244+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
245+
SOFTWARE.
246+
247+
[npm]: https://img.shields.io/npm/v/html-loader.svg
248+
[npm-url]: https://npmjs.com/package/html-loader
249+
250+
[deps]: https://david-dm.org/webpack/html-loader.svg
251+
[deps-url]: https://david-dm.org/webpack/html-loader
252+
253+
[chat]: https://img.shields.io/badge/gitter-webpack%2Fwebpack-brightgreen.svg
254+
[chat-url]: https://gitter.im/webpack/webpack
255+
256+
[test]: http://img.shields.io/travis/webpack/html-loader.svg
257+
[test-url]: https://travis-ci.org/webpack/html-loader
258+
259+
[cover]: https://coveralls.io/repos/github/webpack/html-loader/badge.svg?branch=master
260+
[cover-url]: https://coveralls.io/github/webpack/html-loader?branch=master

0 commit comments

Comments
 (0)