Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged

Conversation

pedrosousa13
Copy link
Contributor

@pedrosousa13 pedrosousa13 commented Jul 28, 2023

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

Copy link
Owner

@marco-prontera marco-prontera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contribution!
After changes, please write some test for these changes

src/utils.ts Outdated Show resolved Hide resolved
src/utils.ts Outdated Show resolved Hide resolved
src/interface.ts Outdated Show resolved Hide resolved
src/interface.ts Outdated Show resolved Hide resolved
src/utils.ts Outdated Show resolved Hide resolved
@pedrosousa13
Copy link
Contributor Author

@marco-prontera I made the requested changes.

Copy link
Owner

@marco-prontera marco-prontera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pedrosousa13, I talked to other contributors about what they think and we ended up not introducing this dependency but changing the styleId so that it is also possible to configure a callback which in this case will be called every time for every css file injection.
Can you change the code?

@pedrosousa13
Copy link
Contributor Author

yeah totally. will make the change.

@pedrosousa13
Copy link
Contributor Author

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

@marco-prontera marco-prontera changed the title feat: allow for unique styleId when relativeCSSInjection [#111] Make styleId an optional string or function Aug 7, 2023
@marco-prontera marco-prontera linked an issue Aug 7, 2023 that may be closed by this pull request
@marco-prontera marco-prontera changed the base branch from main to develop August 7, 2023 19:37
@marco-prontera marco-prontera merged commit 8e1a392 into marco-prontera:develop Aug 7, 2023
1 check passed
marco-prontera added a commit that referenced this pull request Aug 7, 2023
* feat: allow for unique styleId when relativeCssInjection

* fix: remove dash when there is no styleId

* fix: only run changes if styleId exists

* fix: move uuid to devDependencies + update README

* fix: PR comments

* fix: remove empty line

* fix: remove empty line

* fix: remove empty line

* fix: remove unused duplicate test

* refactor: styleId as callback function
3.3.0
@marco-prontera
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make styleId an optional string or function
2 participants