marco-prontera / vite-plugin-css-injected-by-js

A Vite plugin that takes the CSS and adds it to the page through the JS. For those who want a single JS file.
MIT License
429 stars 26 forks source link

[#111] Make styleId an optional string or function #110

Closed pedrosousa13 closed 1 year ago

pedrosousa13 commented 1 year ago

We have a build that builds out css with relativeCSSInjection. I would like to have style tags with different id's as so not to clash.

Using this with the SSR approach that I modified in my style injection function works really well https://github.com/egoist/style-inject/pull/28/files

Styles are loaded via SSR with different id attributes. This will only run if styleId is specified.

I'm adding this PR because I need the id to be the same for server + client so I need it at the vite level.

closes #111

pedrosousa13 commented 1 year ago

@marco-prontera I made the requested changes.

pedrosousa13 commented 1 year ago

yeah totally. will make the change.

pedrosousa13 commented 1 year ago

@marco-prontera changes made, it now accepts a callback function. I also like this implementation :)

marco-prontera commented 1 year ago

Hi @pedrosousa13, I published the new version 3.3.0 Thank you for the contribution 🥳