You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|**[`filename`](#filename)**|`{String\|Function}`|`[name].css`| This option determines the name of each output CSS file |
81
+
|**[`chunkFilename`](#chunkFilename)**|`{String\|Function}`|`based on filename`| This option determines the name of non-entry chunk files |
82
+
|**[`ignoreOrder`](#ignoreOrder)**|`{Boolean}`|`false`| Remove Order Warnings |
83
+
|**[`insert`](#insert)**|`{String\|Function}`|`var head = document.getElementsByTagName("head")[0];head.appendChild(linkTag);`| Inserts `<link>` at the given position |
83
84
84
85
#### `filename`
85
86
@@ -109,6 +110,57 @@ Default: `false`
109
110
Remove Order Warnings.
110
111
See [examples](#remove-order-warnings) below for details.
111
112
113
+
#### `insert`
114
+
115
+
Type: `String|Function`
116
+
Default: `var head = document.getElementsByTagName("head")[0];head.appendChild(linkTag);`
117
+
118
+
By default, the `extract-css-chunks-plugin` appends styles (`<link>` elements) to `document.head` of the current `window`.
119
+
120
+
However in some circumstances it might be necessary to have finer control over the append target or even delay `link` elements instertion.
121
+
For example this is the case when you asynchronously load styles for an application that runs inside of an iframe.
122
+
In such cases `insert` can be configured to be a function or a custom selector.
123
+
124
+
If you target an [iframe](https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement) make sure that the parent document has sufficient access rights to reach into the frame document and append elements to it.
125
+
126
+
##### `String`
127
+
128
+
Allows to setup custom [query selector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector).
129
+
A new `<link>` element will be inserted after the found item.
130
+
131
+
**webpack.config.js**
132
+
133
+
```js
134
+
newMiniCssExtractPlugin({
135
+
insert:'#some-element',
136
+
});
137
+
```
138
+
139
+
A new `<link>` element will be inserted after the element with id `some-element`.
140
+
141
+
##### `Function`
142
+
143
+
Allows to override default behavior and insert styles at any position.
144
+
145
+
> ⚠ Do not forget that this code will run in the browser alongside your application. Since not all browsers support latest ECMA features like `let`, `const`, `arrow function expression` and etc we recommend you to use only ECMA 5 features and syntax.
146
+
147
+
> > ⚠ The `insert` function is serialized to string and passed to the plugin. This means that it won't have access to the scope of the webpack configuration module.
0 commit comments