vite-plugin-lib-inject-css icon indicating copy to clipboard operation
vite-plugin-lib-inject-css copied to clipboard

CSS file imports are appearing above banner section

Open MTG2000 opened this issue 1 year ago • 4 comments

Hi So I'm using this library in building a React library that is supposed to work in Next.js. As you know in Next.js 13+, you need to have a "use client"; directive at the top of each component file.

This is usually achieved in vite by adding the "use client"; directive as a banner. But this library puts the css imports at the top of the file, so the directives are not working.

Is there a way to make the css imports appear after the banner? Or should I be tackling this issue using something other than banners completely??

Thanks for your help.

MTG2000 avatar Apr 26 '24 06:04 MTG2000

Yes, I was about to do it originally as what your said. For now this plugin just adds a line and is not using AST analysis. The CSS injection supposes to be put at the end of the import statement blocks. But I have no time to work on this these days, maybe someone can pull a request? 😄 It's simple.

emosheeep avatar Apr 26 '24 07:04 emosheeep

Maybe I can have it done in a certain weekend in the future.

emosheeep avatar Apr 26 '24 07:04 emosheeep

I've published 2.1.0-beta.0, you can have a try.

emosheeep avatar Apr 26 '24 15:04 emosheeep

Hey @emosheeep Thanks a lot for the quick update! I tried the new version, & it's working 👌

MTG2000 avatar Apr 26 '24 18:04 MTG2000

v2.1.0 has been published.

emosheeep avatar May 09 '24 04:05 emosheeep