Open
Description
Context
I want to generate a standalone component to be loaded in a shadow DOM.
It seems that this gets me most of what I need:
- own JS chunk
- standalone CSS chunk that includes all the CSS dependencies (sub-imports of other .css files)
import shadow from 'react-shadow';
/// partial, pseudo-code
const {Component} = await import('./Component');
return <shadow.div><Component/></shadow.div>
At this point, a Component.css
file is being generated and appended to document.head
.
**The problem is that this stylesheet should be inside shadow.div
Feature Proposal
I'm not sure what would be the best way to achieve this, but perhaps:
- add a magic comment to the
import()
to disable the automatic injection of the stylesheet
e.g.import(/* webpackCss: no-inject */ './Component');
- return the URL as an additional property, so that it can be handled autonomously
e.g.const {Component, __miniCssUrl} = await import('./Component');
Related links
- adoptedStyleSheets could be later used to inject the stylesheet in the shadow DOM: https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/adoptedStyleSheets
- you can see here how they currently load the CSS (i.e. as string in JS, mostly) https://github.com/Wildhoney/ReactShadow
- similar request in Path of extracted css file #110
- part of this request Async loading of CSS bundle #204
Metadata
Metadata
Assignees
Labels
No labels