Skip to content

Commit 2e9b800

Browse files
committed
Update README.md
1 parent 833d279 commit 2e9b800

File tree

1 file changed

+62
-6
lines changed

1 file changed

+62
-6
lines changed

README.md

+62-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Require [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-ex
1010
## Install
1111
#### NPM
1212
```bash
13-
npm install html-inline-css-webpack-plugin -D
13+
npm i html-inline-css-webpack-plugin -D
1414
```
1515
#### Yarn
1616
```bash
@@ -50,18 +50,74 @@ module.exports = {
5050
```typescript
5151
interface Config {
5252
filter?(fileName: string): boolean
53+
replace?: {
54+
target: string
55+
position?: 'before' | 'after'
56+
removeTarget?: boolean
57+
}
5358
}
5459
```
5560

5661
### filter(optional)
62+
```typescript
63+
filter?(fileName: string): boolean
64+
```
5765
Return `true` to make current file internal, otherwise ignore current file.
5866
##### example
5967
```typescript
6068
...
61-
new HTMLInlineCSSWebpackPlugin({
62-
filter(fileName) {
63-
return fileName.includes('main');
64-
},
65-
}),
69+
new HTMLInlineCSSWebpackPlugin({
70+
filter(fileName) {
71+
return fileName.includes('main');
72+
},
73+
}),
6674
...
6775
```
76+
77+
### replace(optional)
78+
```typescript
79+
replace?: {
80+
target: string
81+
position?: 'before' | 'after' // default is 'before'
82+
removeTarget?: boolean // default is false
83+
}
84+
```
85+
A config for customizing the location of injection, default will add internal style sheet before the `</head>`
86+
#### target
87+
A target for adding the internal style sheet
88+
#### position(optional)
89+
Add internal style sheet `before`/`after` the `target`
90+
#### removeTarget(optional)
91+
if `true`, it will remove the `target` from the output HTML
92+
93+
##### example
94+
```html
95+
<head>
96+
<!-- inline_css_plugin -->
97+
<style>
98+
/* some hard code style */
99+
</style>
100+
</head>
101+
```
102+
103+
```typescript
104+
...
105+
new HTMLInlineCSSWebpackPlugin({
106+
replace: {
107+
removeTarget: true,
108+
target: '<!-- inline_css_plugin -->',
109+
},
110+
}),
111+
...
112+
```
113+
###### output:
114+
```html
115+
<head>
116+
<style>
117+
/* style from *.css files */
118+
</style>
119+
<style>
120+
/* some hard code style */
121+
</style>
122+
</head>
123+
```

0 commit comments

Comments
 (0)