Skip to content

astro with tailwind incorrect style css order in subpath #5676

Closed

Description

@herve-ch

What version of astro are you using?

1.7.2

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

Netlify

What package manager are you using?

yarn

What operating system are you using?

Mac

Describe the Bug

css files (with tailwind) in subpath (like http://website/subfolder) are imported in the wrong order and custom styles get overridden

it only happen when building for production, local dev is correct, I tried with deno and netlify

it works correctly with astro 1.6.14

i set up a sample in netlify:

Compare:
https://verdant-kashata-5415d3.netlify.app/test/
https://verdant-kashata-5415d3.netlify.app/

=> TEST H1 in https://verdant-kashata-5415d3.netlify.app/test/
is not styled with global css, it is overridden, it should be like in https://verdant-kashata-5415d3.netlify.app/

source code : https://github.com/herve-ch/astro-tw

Link to Minimal Reproducible Example

https://github.com/herve-ch/astro-tw

Participation

  • I am willing to submit a pull request for this issue.

Activity

  1. herve-ch commented on Jan 7, 2023

    @herve-ch
    Author

    updated to astro 1.9.1 and still the same problem, am I missing something?

  2. matthewp commented on Jan 27, 2023

    @matthewp
    Contributor

    Sorry for not responding earlier, we were busy with 2.0 issues. I'm taking a look at this now.

  3. self-assigned this
    on Jan 27, 2023
  4. added
    - P4: important
    on Jan 27, 2023
  5. matthewp commented on Jan 27, 2023

    @matthewp
    Contributor

    I would think that this issue shouldn't require an SSR adapter, right? Does this not happen with SSG mode @herve-ch ?

  6. herve-ch commented on Jan 28, 2023

    @herve-ch
    Author

    Hello @matthewp I just updated to latest astro 2.0.2 and netlify adapter and now it happen on both local and netlify deployment.
    It happens on both SSG and SSR mode

    https://verdant-kashata-5415d3.netlify.app/test/ <-- Tailwind global css are overriden
    https://verdant-kashata-5415d3.netlify.app/

    Thanks for your awesome work

  7. JerryWu1234 commented on Jan 31, 2023

    @JerryWu1234
    Contributor

    Hello @matthewp I just updated to latest astro 2.0.2 and netlify adapter and now it happen on both local and netlify deployment. It happens on both SSG and SSR mode

    https://verdant-kashata-5415d3.netlify.app/test/ <-- Tailwind global css are overriden https://verdant-kashata-5415d3.netlify.app/

    Thanks for your awesome work

    You meant that the below code didn't run in the test folder. Right?

    <style lang="postcss">
    
    		:global(h1) {
    			@apply text-5xl font-semibold w-full mb-4;
    		}
    </style>

    I only have seen different CSS.

  8. herve-ch commented on Jan 31, 2023

    @herve-ch
    Author

    Hello @matthewp I just updated to latest astro 2.0.2 and netlify adapter and now it happen on both local and netlify deployment. It happens on both SSG and SSR mode
    https://verdant-kashata-5415d3.netlify.app/test/ <-- Tailwind global css are overriden https://verdant-kashata-5415d3.netlify.app/
    Thanks for your awesome work

    You meant that the below code didn't run in the test folder. Right?

    <style lang="postcss">
    
    		:global(h1) {
    			@apply text-5xl font-semibold w-full mb-4;
    		}
    </style>

    I only have seen different CSS.

    I'm sorry my sample was not correct. I corrected it and I'm using a BaseLayout.

    https://verdant-kashata-5415d3.netlify.app/ --> H1 appear correctly

    https://verdant-kashata-5415d3.netlify.app/test/ -->H1 doesn't get styled with the same global style

    The 2 pages use same BaseLayout with global style on h1. There is only <h1>TEST</h1> in BaseLayout

    There is a MarkdownPostLayout that import BaseLayout

    I noticed the bug happen when I'm fetching posts in /pages/test/index.astro:
    with const allPosts = await Astro.glob("../posts/*.md");
    if I remove this line, H1 is displayed correctly.

    Edit:

    1- It happen only when I deploy on netlify or deploying with deno! Local dev (astro dev) is correct
    2- It happen with SSR or SSG
    3- I have to put !important rules on global css to make it work, that's not recommended I think

    Thanks @matthewp @wulinsheng123

  9. JerryWu1234 commented on Feb 1, 2023

    @JerryWu1234
    Contributor

    I got it.
    the same problem that is the CSS order.
    image

  10. matthewp commented on Feb 2, 2023

    @matthewp
    Contributor

    Thanks! Taking a look tomorrow.

  11. matthewp commented on Feb 8, 2023

    @matthewp
    Contributor

    Got a fix, just need to figure out how to test this scenario.

  12. matthewp commented on Feb 8, 2023

    @matthewp
    Contributor

    Fix is in #6176

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

- P4: important

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions