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

Tailwind added after my style block clearing all styles #8044

Closed
1 task done
kubre opened this issue Aug 11, 2023 · 5 comments · Fixed by vitejs/vite#14465
Closed
1 task done

Tailwind added after my style block clearing all styles #8044

kubre opened this issue Aug 11, 2023 · 5 comments · Fixed by vitejs/vite#14465
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) pkg: tailwind

Comments

@kubre
Copy link

kubre commented Aug 11, 2023

What version of astro are you using?

2.10.7

Are you using an SSR adapter? If so, which one?

Vercel

What package manager are you using?

pnpm

What operating system are you using?

Windows

What browser are you using?

Chrome, Firefox

Describe the Bug

I'm using the tailwind plugin for Astro, after updating Astro to the latest version it started adding a tailwind at the end of the head tag(as shown in the image). This causes any style added above to be reset on tags like h1 { @apply bg-black } etc won't work. Downgrading back to the old version 2.0.15 and styles apply fine. Please check stackblitz

image

What's the expected result?

Custom styles should be added after the base styles of the tailwind.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-vbv2yk

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Aug 11, 2023
@kubre
Copy link
Author

kubre commented Aug 12, 2023

If anyone wants a quick fix for now I'm using it .parent class for general tags like h2, p etc. to override the base styles from a tailwind.

/* So rather than using */
h1 { <styles> }

/* Use */
.parent h1 { <styles> }

in HTML you will need

@natemoo-re
Copy link
Member

Sorry for the frustration! This behavior has switched back and forth and we really need to stabilize this.

I'm guessing that this regression was caused by #8011 which switches how we crawl imports to find which styles need to be injected. This likely reverted the crawling order and messed up how styles were being injected during dev.

@natemoo-re natemoo-re added the - P4: important Violate documented behavior or significantly impacts performance (priority) label Aug 14, 2023
@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Aug 14, 2023
@Dunqing
Copy link

Dunqing commented Aug 15, 2023

UnoCSS has the same issue, unocss/unocss#2821

@bluwy
Copy link
Member

bluwy commented Sep 25, 2023

I traced this to a Vite bug. The import order was not preserved by Vite dev module graph which caused the CSS to be out of order too. vitejs/vite#14465

@bluwy
Copy link
Member

bluwy commented Sep 26, 2023

Going to close this for now as the work is done, and the fix is upstream. I'll look into backporting and releasing a patch for Vite 4 perhaps around this week or so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) pkg: tailwind
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants
@natemoo-re @kubre @Dunqing @bluwy and others