@@ -826,7 +826,7 @@ class MiniCssExtractPlugin {
826826
827827 return Template . asString ( [
828828 `var createStylesheet = ${ runtimeTemplate . basicFunction (
829- "chunkId, fullhref, resolve, reject" ,
829+ "chunkId, fullhref, oldTag, resolve, reject" ,
830830 [
831831 'var linkTag = document.createElement("link");' ,
832832 this . runtimeOptions . attributes
@@ -886,7 +886,13 @@ class MiniCssExtractPlugin {
886886 `var target = document.querySelector("${ this . runtimeOptions . insert } ");` ,
887887 `target.parentNode.insertBefore(linkTag, target.nextSibling);` ,
888888 ] )
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+ ] ) ,
890896 "return linkTag;" ,
891897 ]
892898 ) } ;`,
@@ -919,7 +925,7 @@ class MiniCssExtractPlugin {
919925 `var href = ${ RuntimeGlobals . require } .miniCssF(chunkId);` ,
920926 `var fullhref = ${ RuntimeGlobals . publicPath } + href;` ,
921927 "if(findStylesheet(href, fullhref)) return resolve();" ,
922- "createStylesheet(chunkId, fullhref, resolve, reject);" ,
928+ "createStylesheet(chunkId, fullhref, null, resolve, reject);" ,
923929 ]
924930 ) } );`
925931 ) } `,
@@ -995,7 +1001,7 @@ class MiniCssExtractPlugin {
9951001 `promises.push(new Promise(${ runtimeTemplate . basicFunction (
9961002 "resolve, reject" ,
9971003 [
998- `var tag = createStylesheet(chunkId, fullhref, ${ runtimeTemplate . basicFunction (
1004+ `var tag = createStylesheet(chunkId, fullhref, oldTag, ${ runtimeTemplate . basicFunction (
9991005 "" ,
10001006 [
10011007 'tag.as = "style";' ,
0 commit comments