this is very interesting, thank you! I did not yet try to use this approach within a Next.js project.
You can also remove the inject-css plugin (and the sideEffects from the package.json)
Having done that you should be able to just import the generated css file (dist/assets/style.css) inside your Next.js project. But of course you will not have the css treeshaking advantages with this approach.
Generally there are answers for the quetions raised in the linked issue:
Should the file be consumed as Global CSS or CSS Modules?
As Global CSS.
If Global, in what order does the file need to be injected?
The order of the individual files is determined by the order they are imported inside the libraries main file. And the order in the consuming application should not matter.
Maybe it would be possible to write a Next.js plugin enabling this.
What do you think?
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Vesa,
this is very interesting, thank you! I did not yet try to use this approach within a Next.js project.
You can also remove the inject-css plugin (and the
sideEffects
from thepackage.json
)Having done that you should be able to just import the generated css file (
dist/assets/style.css
) inside your Next.js project. But of course you will not have the css treeshaking advantages with this approach.I published a branch with this approach here: github.com/receter/my-component-li...
Generally there are answers for the quetions raised in the linked issue:
As Global CSS.
The order of the individual files is determined by the order they are imported inside the libraries main file.
And the order in the consuming application should not matter.Maybe it would be possible to write a Next.js plugin enabling this.
What do you think?