-
|
Qquestion description: If I'm using a third-party component with a global style, All third-party components are bundle into chunks. Example:
const BaseCssComponent = () => {
return (
<div>
<style global jsx>{`
html {
font-size: 30px;
}
`}</style>
</div>
)
}
I Want: Some of the solutions I've tried:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
I think I solved the problem.
As a solution, you can export the Example: In your component library: // in next.js class MyDocument extends Document {
static async getInitialProps (ctx) {
const initialProps = await Document.getInitialProps(ctx)
const styles = BaseCssComponent.flush()
return {
...initialProps,
styles: (
<>
{initialProps.styles}
{styles}
</>
)
}
}
...
} |
Beta Was this translation helpful? Give feedback.
-
|
I am not sure this is the reason, but is |
Beta Was this translation helpful? Give feedback.


I think I solved the problem.
Update results, may be helpful to others.
(🙏 can anyone help me close this discussion?)
styled-jsxcannot collect styles fromnode_modules, even if these style components are generated withstyled-jsx.As a solution, you can export the
flushofstyled-jsx/servermanually in the library, only in this way, we cat get styleSheetRegistry instance.Example:
In your component library: