File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,9 @@ class MiniCssExtractPlugin {
117
117
} ,
118
118
options
119
119
) ;
120
+ if ( typeof this . options . insertInto !== 'function' ) {
121
+ throw new Error ( 'insertInto option must be a function' ) ;
122
+ }
120
123
if ( ! this . options . chunkFilename ) {
121
124
const { filename } = this . options ;
122
125
const hasName = filename . includes ( '[name]' ) ;
@@ -324,6 +327,9 @@ class MiniCssExtractPlugin {
324
327
contentHashType : MODULE_TYPE ,
325
328
}
326
329
) ;
330
+ const insertInto = this . options . insertInto
331
+ ? this . options . insertInto . toString ( )
332
+ : 'null' ;
327
333
return Template . asString ( [
328
334
source ,
329
335
'' ,
@@ -379,8 +385,8 @@ class MiniCssExtractPlugin {
379
385
'}' ,
380
386
] )
381
387
: '' ,
382
- `var selector = " ${ this . options . insertInto } " ;` ,
383
- 'var parent = selector && document.querySelector && document.querySelector(selector) ;' ,
388
+ `var insertInto = ${ insertInto } ;` ,
389
+ 'var parent = insertInto ? insertInto(href) : null ;' ,
384
390
'if (parent) { parent.appendChild(linkTag); }' ,
385
391
'else { document.getElementsByTagName("head")[0].appendChild(linkTag); }' ,
386
392
] ) ,
You can’t perform that action at this time.
0 commit comments