@@ -826,7 +826,7 @@ class MiniCssExtractPlugin {
826
826
827
827
return Template . asString ( [
828
828
`var createStylesheet = ${ runtimeTemplate . basicFunction (
829
- "chunkId, fullhref, resolve, reject" ,
829
+ "chunkId, fullhref, oldTag, resolve, reject" ,
830
830
[
831
831
'var linkTag = document.createElement("link");' ,
832
832
this . runtimeOptions . attributes
@@ -886,7 +886,13 @@ class MiniCssExtractPlugin {
886
886
`var target = document.querySelector("${ this . runtimeOptions . insert } ");` ,
887
887
`target.parentNode.insertBefore(linkTag, target.nextSibling);` ,
888
888
] )
889
- : Template . asString ( [ "document.head.appendChild(linkTag);" ] ) ,
889
+ : Template . asString ( [
890
+ "if (oldTag) {" ,
891
+ Template . indent ( [ "oldTag.after(linkTag);" ] ) ,
892
+ "} else {" ,
893
+ Template . indent ( [ "document.head.appendChild(linkTag);" ] ) ,
894
+ "}" ,
895
+ ] ) ,
890
896
"return linkTag;" ,
891
897
]
892
898
) } ;`,
@@ -919,7 +925,7 @@ class MiniCssExtractPlugin {
919
925
`var href = ${ RuntimeGlobals . require } .miniCssF(chunkId);` ,
920
926
`var fullhref = ${ RuntimeGlobals . publicPath } + href;` ,
921
927
"if(findStylesheet(href, fullhref)) return resolve();" ,
922
- "createStylesheet(chunkId, fullhref, resolve, reject);" ,
928
+ "createStylesheet(chunkId, fullhref, null, resolve, reject);" ,
923
929
]
924
930
) } );`
925
931
) } `,
@@ -995,7 +1001,7 @@ class MiniCssExtractPlugin {
995
1001
`promises.push(new Promise(${ runtimeTemplate . basicFunction (
996
1002
"resolve, reject" ,
997
1003
[
998
- `var tag = createStylesheet(chunkId, fullhref, ${ runtimeTemplate . basicFunction (
1004
+ `var tag = createStylesheet(chunkId, fullhref, oldTag, ${ runtimeTemplate . basicFunction (
999
1005
"" ,
1000
1006
[
1001
1007
'tag.as = "style";' ,
0 commit comments