Skip to content

Commit 40c152a

Browse files
update README
1 parent b4ece5a commit 40c152a

File tree

3 files changed

+85
-19
lines changed

3 files changed

+85
-19
lines changed

README.md

Lines changed: 83 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,10 @@ Webpack loader for [PostHTML](https://github.com/posthtml/posthtml)
99
```
1010

1111
## Usage
12-
### Inline
12+
### Setup
1313

1414
```javascript
15-
// file.js
16-
17-
var html = require('html!posthtml!./file.html')
18-
```
19-
20-
### Config
21-
22-
```javascript
23-
// webpack.config.js || webpackfile.js
15+
// webpack.config.js
2416

2517
module: {
2618
loaders: [
@@ -34,7 +26,7 @@ module: {
3426
posthtml: function () {
3527
return {
3628
defaults: [ PostHTML Plugins ]
37-
// Add Plugin Packs
29+
// Add our own Plugin Packs
3830
}
3931
}
4032
```
@@ -47,20 +39,94 @@ module.exports = {
4739
module: {
4840
loaders: [
4941
{
50-
test: /\.includes\.html$/,
42+
test: /\.html$/,
43+
loader: 'html!posthtml'
44+
}
45+
{
46+
test: /\.include\.html$/,
5147
loader: 'html!posthtml?pack=includes'
52-
},
48+
}
49+
]
50+
},
51+
52+
posthtml: function () {
53+
return {
54+
defaults: [ PostHTML Plugins ],
55+
includes: [ PostHTML Plugins ]
56+
}
57+
}
58+
}
59+
```
60+
61+
### Examples
62+
with [jade-html-loader](https://github.com/bline/jade-html-loader)
63+
64+
```javascript
65+
66+
module.exports = {
67+
module: {
68+
loaders: [
5369
{
54-
test: /\.html$/,
55-
loader: 'html!posthtml'
70+
test: /\.html$/,
71+
loader: 'html!posthtml!jade-html'
72+
}
73+
]
74+
},
75+
76+
posthtml: function () {
77+
return {
78+
defaults: [ PostHTML Plugins ]
79+
}
80+
}
81+
}
82+
```
83+
84+
with [dom-loader](https://github.com/Wizcorp/dom-loader)
85+
86+
```javascript
87+
88+
module.exports = {
89+
module: {
90+
loaders: [
91+
{
92+
test: /\.html$/,
93+
loader: 'dom!html!posthtml'
5694
}
5795
]
5896
},
5997

6098
posthtml: function () {
6199
return {
62-
defaults: [PostHTML Plugins],
63-
includes: [PostHTML Plugins]
100+
defaults: [ PostHTML Plugins ]
64101
}
102+
}
103+
}
104+
```
105+
106+
with [extract-text-plugin](https://github.com/webpack/extract-text-webpack-plugin)
107+
108+
```javascript
109+
110+
var ExtractText = require('extract-text-webpack-plugin')
111+
112+
module.exports = {
113+
module: {
114+
loaders: [
115+
{
116+
test: /\.html$/,
117+
loader: ExtractText.extract('html!posthtml')
118+
}
119+
]
120+
},
121+
122+
posthtml: function () {
123+
return {
124+
defaults: [ PostHTML Plugins ]
125+
}
126+
},
127+
128+
plugins: [
129+
new ExtractText('output.html')
130+
]
65131
}
66132
```

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = function (source) {
2020
if (options.pack) {
2121
plugins = plugins[options.pack]
2222
}
23-
if (typeof plugins === 'undefined') {
23+
if (typeof plugins === 'undefined' || typeof plugins === 'object') {
2424
plugins = []
2525
}
2626

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "posthtml-loader",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"engine": ">=4",
55
"main": "index.js",
66
"dependencies": {

0 commit comments

Comments
 (0)