You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Do not do a second render pass on Svelte `<style>` tags.
if(isSvelteStyle(id))continue
letgenerated=awaitregenerateOptimizedCss(
root,
// During the renderStart phase, we can not add watch files since
// those would not be causing a refresh of the right CSS file. This
// should not be an issue since we did already process the CSS file
// before and the dependencies should not be changed (only the
// candidate list might have)
()=>{},
)
if(!generated){
roots.delete(id)
continue
}
// These plugins have side effects which, during build, results in CSS
// being written to the output dir. We need to run them here to ensure
// the CSS is written before the bundle is generated.
awaittransformWithPlugins(this,id,generated)
}
},
...and the fact that LightningCSS is run against the source code before postcss is. The renderStart hook above is only applied for build phase, hence the misaligned behavior compared to dev mode.
@RobinMalfait mentioned similar issue in LightningCSS repo at parcel-bundler/lightningcss#353. It is true these at-rules are not standard CSS but given their usefulness I suspect we will see more and more people observing similar issues once they try to migrate to V4, especially because V3 was a postcss plugin itself.
To me, it'd be ideal if we could run LightningCSS after Postcss (renderStart after vite:css?) in @tailwindcss/vite, which will better match with behavior during dev mode and do not require changes from LightningCSS side.
I did also try setting up custom transform for LightningCSS but so far no straightforward (or even possible) one to work around this issue.
Thanks all.
The text was updated successfully, but these errors were encountered:
vnphanquang
changed the title
[v4] Nested unknown at-Rule (for PostCSS plugins) are ejected from rule during build
[v4] Nested unknown at-rule (for PostCSS plugins) are ejected from rule during build
Nov 26, 2024
vnphanquang
changed the title
[v4] Nested unknown at-rule (for PostCSS plugins) are ejected from rule during build
[v4] Nested unknown at-rule (for PostCSS plugins) is ejected from rule during build
Nov 26, 2024
@Robert344Humphries you can try using tailwind v4 as a postcss plugin instead of vite plugin. If your setup is not too complex, that may be a viable workaround at the moment. Also if possible can you include some more info about the at-rule / postcss plugin you are having problem with here? That might be helpful for further debugging. Thanks
Version
[email protected]
and@tailwindcss/[email protected]
Environment
Output of
npx envinfo --system --binaries --browsers --npmPackages "{vite,tailwindcss,@tailwindcss/*,postcss-mixins}"
:Reproduction
https://github.com/vnphanquang/tailwind-4-at-rule-build-reproduction. Please see README for steps and expected output.
Or better, use this suggested test case:
Expand test case
Description
Originally reported in #14973 (comment) but after digging I've narrowed it down to this.
There are a few things I want to say about this issue so please bear with me. Given this CSS:
Assuming postcss-mixins is registered appropriately in config. Everything is fine in dev mode. But for production build, this is the output:
After tracing through Tailwind codebase, I believe it is likely because of this code...
tailwindcss/packages/@tailwindcss-vite/src/index.ts
Lines 270 to 294 in 98359be
...and the fact that LightningCSS is run against the source code before postcss is. The
renderStart
hook above is only applied for build phase, hence the misaligned behavior compared to dev mode.As of this writing LightningCSS will extract out any unknown at rule nested inside a rule. Try the code above in LightningCSS playground and notice position of
@mixin vite
.@RobinMalfait mentioned similar issue in LightningCSS repo at parcel-bundler/lightningcss#353. It is true these at-rules are not standard CSS but given their usefulness I suspect we will see more and more people observing similar issues once they try to migrate to V4, especially because V3 was a postcss plugin itself.
To me, it'd be ideal if we could run LightningCSS after Postcss (
renderStart
aftervite:css
?) in@tailwindcss/vite
, which will better match with behavior during dev mode and do not require changes from LightningCSS side.I did also try setting up custom transform for LightningCSS but so far no straightforward (or even possible) one to work around this issue.
Thanks all.
The text was updated successfully, but these errors were encountered: