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

Postcss: Run plugin in Once hook #15273

Merged
merged 6 commits into from
Dec 3, 2024

Conversation

philipp-spiess
Copy link
Member

Closes #15138

This PR changes the postcss client to run in the Once hook instead of OnceExit. This makes sure the postcss order in v4 matches that of v3.

Conceptually this also makes more sense, since we expect tailwindcss to be run as one of the first plugins in the pipeline (where OnceExit would run it almost at the end).

To make sure it's still possible to use postcss-import before and have it resolve to the right paths, we also needed to change the postcss-fix-relative-paths plugin to run in the Once order (postcss-import also uses Once order so the order).

Test Plan

This issue had many ways in which it can manifest. I added a unit test to ensure the plugin order works but here's a concrete example when using the postcss plugin in Vite.

Before

Image url()s were not properly handled since the postcss plugin to transform these was run before Tailwind CSS could generate the class for it:

Screenshot 2024-12-02 at 14 55 42

After

Screenshot 2024-12-02 at 14 53 52

@philipp-spiess philipp-spiess requested a review from a team as a code owner December 2, 2024 13:57
### Fixed

- Ensure other plugins can run after `@tailwindcss/postcss` ([#15273](https://github.com/tailwindlabs/tailwindcss/pull/15273))
- Rebase `url()` inside imported CSS files when using Vite with the `@tailwindcss/postcss` extension ([#15273](https://github.com/tailwindlabs/tailwindcss/pull/15273))
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have a test for this specifically?

@philipp-spiess philipp-spiess merged commit 5454014 into next Dec 3, 2024
1 check passed
@philipp-spiess philipp-spiess deleted the fix/move-postcss-plugin-to-once-order branch December 3, 2024 09:28
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.

[v4] Plugins registered after @tailwindcss/postcss do not work
2 participants