Skip to content
This repository was archived by the owner on May 31, 2021. It is now read-only.

Commit 869b207

Browse files
fix: addressing comments from webpack on insert-string
1 parent 7b0afeb commit 869b207

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

src/index.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,8 @@ class CssModuleFactory {
101101
class ExtractCssChunksPlugin {
102102
constructor(options = {}) {
103103
validateOptions(schema, options, 'Mini CSS Extract Plugin');
104-
const insert =
105-
typeof options.insert === 'undefined'
106-
? '"head"'
107-
: typeof options.insert === 'string'
108-
? JSON.stringify(options.insert)
109-
: options.insert.toString();
104+
105+
const insert = options.insert ? options.insert.toString() : null;
110106
this.options = Object.assign(
111107
{
112108
filename: DEFAULT_FILENAME,
@@ -382,9 +378,9 @@ class ExtractCssChunksPlugin {
382378
'}',
383379
])
384380
: '',
385-
`var insert = ${insert};`,
386-
`if (typeof insert === 'function') { insert(linkTag); }`,
387-
`else { var target = document.querySelector(${insert}); target && insert === 'body' ? target && target.insertBefore(linkTag,target.firstChild) : target.appendChild(linkTag); } `,
381+
insert
382+
? 'insert(linkTag);'
383+
: 'var head = document.getElementsByTagName("head")[0]; head.appendChild(linkTag)',
388384
]),
389385
'}).then(function() {',
390386
Template.indent(['installedCssChunks[chunkId] = 0;']),

test/cases/insert-string/style.css

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)