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 {
1818}
1919
2020export 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 ) {
2723 return html . replace (
2824 new RegExp ( `<link[^>]+href=['"]${ cssFileName } ['"][^>]+(>|\/>|><\/link>)` ) ,
29- '' ,
30- ) ;
25+ `<style> ${ style } </style>`
26+ ) ;
3127 }
3228
3329 private config : Config ;
@@ -71,8 +67,7 @@ export default class Plugin
7167 let html = this . html [ htmlFileName ] ;
7268
7369 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 ) ;
7671 } ) ;
7772
7873 assets [ htmlFileName ] = {
@@ -94,4 +89,4 @@ export default class Plugin
9489function is ( filenameExtension : string ) {
9590 const reg = new RegExp ( `\.${ filenameExtension } $` ) ;
9691 return ( fileName : string ) => reg . test ( fileName ) ;
97- }
92+ }
You can’t perform that action at this time.
0 commit comments