Postcss: Run plugin in Once
hook
#15273
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #15138
This PR changes the postcss client to run in the
Once
hook instead ofOnceExit
. 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 thepostcss-fix-relative-paths
plugin to run in theOnce
order (postcss-import
also usesOnce
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:After