-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Vite injected styles and Astro injected styles are conflicting #8637
Comments
Hello @marceloverdijk. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with |
This is the GitHub repo https://github.com/sarvex/afraid-aurora containing the code The problem is seen with the current NodeJS version 20.7. with LTS 18.18, the problem is not there |
Thx @sarvex for sharing you repo. |
@marceloverdijk there is something weird going on... |
That's exactly what it is, and it's best to understand the underlying problem and why the order isn't fixable today. As you said, in CSS land, order is important. Now, let's say you have a component that imports a style. Then this component is imported in two pages, in one page is imported at the top of the import statements, and in the other page is imported at the bottom of the import statements. The bundler doesn't know the priority of the styles attached to the component, because its order is different in the two pages. Myself and Matthew talked about it a lot, and as for today, this is an issue that is fixible by end users by understanding the order of the styles. We also talked about introducing some new configuration to mitigate the problem, although fixing isn't as easy. |
I'm trying to understand. And yes if multiple components ordering is probably diffcult. I have just 1 base Layout used by all pages, and that Layout does the scss include by:
|
Thinking about a bit more, I wonder if there would be a way to bypass the mechanism importing styles in some way. |
@marceloverdijk I checked out your example and I don't see |
It's indeed a different example from @sarvex . This is the original repo I had: https://github.com/marceloverdijk/astro-7508 This should contain these classes. |
I'm able to fix the duplicated styles @marceloverdijk, but it doesn't seem to affect the spacing issue you mentioned before. I guess there's something affecting it but I'm not sure what. @sarvex I can't seem to see any duplicated styles in your repro. I thinking it's a separate issue if it's only happening on specific machines. Maybe you can try after this issue's fixed as I refactored CSS and HMR overall. |
Thx @bluwy I will try it out asap when new release is available 👍 |
Hi @bluwy is there a npm tag or something to try latest from git? Or do you know when this will be released? |
Just released it on Astro v3.2.1 👍 |
I will give it a try this evening and will let you know here. |
Interestingly, I cannot reproduce the issue with Although the setup between 2 projects is similar (and using the same theme scss files) I'm will do further comparisons on my side to try to identify what is causing this. |
Found it and fixed it in the 7508 sample project as well. I will also look into the spacing issue as I'm wondering where that is coming from. Will post updates here. |
@bluwy just for your information I found the origin of the spacing issue. When having html like:
there is linebreak/whitespace in front of these badges. As Astro removes these whitespace in the output the spacing is not there anymore. So instead of e.g. |
Thanks for the updates @marceloverdijk! These are useful information and glad you got it sorted out.
Ah now that you brought it up I remember why now. In Astro 3.0, we have enabled I think that's an intentional change on our end, but it's still good to add the additional CSS for spacing too to futureproof it. |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Yes I also noticed (partially) duplicated css.
E.g. I have a span like:
and the generated css contains:
L28048:
L28116:
L34947:
The
.bg-primary
is for some reason duplicated, but thebg-opacity-10
not.The problem now is that the
--bs-bg-opacity
is overwritten again, causing a styling issue.This new issue is created after discussion here with @bluwy
What's the expected result?
Correct - non duplicate - styling.
Link to Minimal Reproducible Example
https://github.com/marceloverdijk/astro-7508
Participation
The text was updated successfully, but these errors were encountered: