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
Copy file name to clipboardExpand all lines: README.md
+16-3Lines changed: 16 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -139,7 +139,7 @@ Styles are not added on `import/require()`, but instead on call to `use`/`ref`.
139
139
|**`attrs`**|`{Object}`|`{}`|Add custom attrs to `<style></style>`|
140
140
|**`transform`**|`{Function}`|`false`|Transform/Conditionally load CSS by passing a transform/condition function|
141
141
|**`insertAt`**|`{String\|Object}`|`bottom`|Inserts `<style></style>` at the given position|
142
-
|**`insertInto`**|`{String}`|`<head>`|Inserts `<style></style>` into the given position|
142
+
|**`insertInto`**|`{String|Function}`|`<head>`|Inserts `<style></style>` into the given position|
143
143
|**`singleton`**|`{Boolean}`|`undefined`|Reuses a single `<style></style>` element, instead of adding/removing individual elements for each required module.|
|**`convertToAbsoluteUrls`**|`{Boolean}`|`false`|Converts relative URLs to absolute urls, when source maps are enabled|
@@ -318,14 +318,27 @@ A new `<style>` element can be inserted before a specific element by passing an
318
318
319
319
### `insertInto`
320
320
By default, the style-loader inserts the `<style>` elements into the `<head>` tag of the page. If you want the tags to be inserted somewhere else you can specify a CSS selector for that element here. If you target an [IFrame](https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement) make sure you have sufficient access rights, the styles will be injected into the content document head.
321
-
You can also insert the styles into a [ShadowRoot](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot), e.g
321
+
322
+
You can also pass function to override default behavior and insert styles in your container, e.g
323
+
324
+
**webpack.config.js**
325
+
```js
326
+
{
327
+
loader:'style-loader',
328
+
options: {
329
+
insertInto: () =>document.querySelector("#root"),
330
+
}
331
+
}
332
+
```
333
+
334
+
Using function you can insert the styles into a [ShadowRoot](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot), e.g
0 commit comments