File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -129,7 +129,9 @@ class MiniCssExtractPlugin {
129
129
} ,
130
130
options
131
131
) ;
132
-
132
+ if ( typeof this . options . insertInto !== 'function' ) {
133
+ throw new Error ( 'insertInto option must be a function' ) ;
134
+ }
133
135
if ( ! this . options . chunkFilename ) {
134
136
const { filename } = this . options ;
135
137
@@ -363,7 +365,9 @@ class MiniCssExtractPlugin {
363
365
contentHashType : MODULE_TYPE ,
364
366
}
365
367
) ;
366
-
368
+ const insertInto = this . options . insertInto
369
+ ? this . options . insertInto . toString ( )
370
+ : 'null' ;
367
371
return Template . asString ( [
368
372
source ,
369
373
'' ,
@@ -419,8 +423,8 @@ class MiniCssExtractPlugin {
419
423
'}' ,
420
424
] )
421
425
: '' ,
422
- `var selector = " ${ this . options . insertInto } " ;` ,
423
- 'var parent = selector && document.querySelector && document.querySelector(selector) ;' ,
426
+ `var insertInto = ${ insertInto } ;` ,
427
+ 'var parent = insertInto ? insertInto(href) : null ;' ,
424
428
'if (parent) { parent.appendChild(linkTag); }' ,
425
429
'else { document.getElementsByTagName("head")[0].appendChild(linkTag); }' ,
426
430
] ) ,
You can’t perform that action at this time.
0 commit comments