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 core/reset file added after other css files in astro build #4614

Closed
1 task
lukewatts opened this issue Sep 4, 2022 · 6 comments · Fixed by #4724
Closed
1 task

Tailwind core/reset file added after other css files in astro build #4614

lukewatts opened this issue Sep 4, 2022 · 6 comments · Fixed by #4724
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: styling Related to styles (scope)

Comments

@lukewatts
Copy link

lukewatts commented Sep 4, 2022

What version of astro are you using?

1.1.3

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

None

What package manager are you using?

yarn

What operating system are you using?

Windows

Describe the Bug

Tailwind CSS files in build are being added last (or second last), causing tailwind reset file to override scoped (in file) CSS.

To replicate...

  1. install the Blog template
  2. Run astro add tailwind
  3. Run astro build
  4. Go to any page other than Home and check the order of the CSS files. Tailwind is last or second last which breaks the styles

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-vymz2e?file=tsconfig.json,astro.config.mjs,tailwind.config.cjs,package.json,src%2Fconfig.ts,src%2Fenv.d.ts,src%2Fpages%2Fblog.astro,src%2Flayouts%2FBlogPost.astro,dist%2Findex.html&on=stackblitz

Participation

  • I am willing to submit a pull request for this issue.
@lukewatts lukewatts changed the title CSS files are injected/sorted alphabetically in astro build Tailwind core/reset file added after other css files in astro build Sep 4, 2022
@matthewp
Copy link
Contributor

matthewp commented Sep 6, 2022

I think this is related to the general problem of scoped styles being placed before all imported styles, causing imported styles to override them.

@matthewp matthewp added - P4: important Violate documented behavior or significantly impacts performance (priority) feat: styling Related to styles (scope) labels Sep 6, 2022
@matthewp matthewp self-assigned this Sep 7, 2022
@matthewp
Copy link
Contributor

matthewp commented Sep 9, 2022

Is this example even using Tailwind? I don't see the usage.

@matthewp
Copy link
Contributor

matthewp commented Sep 9, 2022

I guess the reset happens anyways?

@matthewp
Copy link
Contributor

matthewp commented Sep 9, 2022

A related issue: #4446

@matthewp
Copy link
Contributor

matthewp commented Sep 9, 2022

Ok, I looked into this a bit. So what is happening here is that you are generating a few bundles but the important ones are:

  1. global.css + Footer.astro
  2. Tailwind reset

Both of these bundles are used on all 9 pages. I'm not sure there's really a way for us to determine which of these bundles should go first and which should go last. From Astro's perspective they both seem equally important as they are used just as much.

Going to look into a couple of options.

@matthewp
Copy link
Contributor

matthewp commented Sep 9, 2022

Ok, I think I have a solution for this based on source order. Need to figure out how to write a test.

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) feat: styling Related to styles (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants