File tree Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -18,16 +18,12 @@ interface Config {
18
18
}
19
19
20
20
export default class Plugin
21
- {
22
- static addStyle ( html : string , style : string ) {
23
- return html . replace ( '</head>' , `<style>${ style } </style></head>` ) ;
24
- }
25
-
26
- static removeLinkTag ( html : string , cssFileName : string ) {
21
+ {
22
+ static replaceLinkWithStyle ( html : string , style : string , cssFileName : string ) {
27
23
return html . replace (
28
24
new RegExp ( `<link[^>]+href=['"]${ cssFileName } ['"][^>]+(>|\/>|><\/link>)` ) ,
29
- '' ,
30
- ) ;
25
+ `<style> ${ style } </style>`
26
+ ) ;
31
27
}
32
28
33
29
private config : Config ;
@@ -71,8 +67,7 @@ export default class Plugin
71
67
let html = this . html [ htmlFileName ] ;
72
68
73
69
Object . keys ( this . css ) . forEach ( ( key ) => {
74
- html = Plugin . addStyle ( html , this . css [ key ] ) ;
75
- html = Plugin . removeLinkTag ( html , publicPath + key ) ;
70
+ html = Plugin . replaceLinkWithStyle ( html , this . css [ key ] , publicPath + key ) ;
76
71
} ) ;
77
72
78
73
assets [ htmlFileName ] = {
@@ -94,4 +89,4 @@ export default class Plugin
94
89
function is ( filenameExtension : string ) {
95
90
const reg = new RegExp ( `\.${ filenameExtension } $` ) ;
96
91
return ( fileName : string ) => reg . test ( fileName ) ;
97
- }
92
+ }
You can’t perform that action at this time.
0 commit comments