@@ -10,7 +10,7 @@ Require [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-ex
10
10
## Install
11
11
#### NPM
12
12
``` bash
13
- npm install html-inline-css-webpack-plugin -D
13
+ npm i html-inline-css-webpack-plugin -D
14
14
```
15
15
#### Yarn
16
16
``` bash
@@ -50,18 +50,74 @@ module.exports = {
50
50
``` typescript
51
51
interface Config {
52
52
filter? (fileName : string ): boolean
53
+ replace? : {
54
+ target: string
55
+ position? : ' before' | ' after'
56
+ removeTarget? : boolean
57
+ }
53
58
}
54
59
```
55
60
56
61
### filter(optional)
62
+ ``` typescript
63
+ filter ? (fileName : string ): boolean
64
+ ` ` `
57
65
Return ` true ` to make current file internal, otherwise ignore current file.
58
66
##### example
59
67
` ` ` typescript
60
68
...
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
+ }),
66
74
...
67
75
` ` `
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