-
-
Notifications
You must be signed in to change notification settings - Fork 242
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 import resolution not working when css loader set to "text" (monorepo only) #770
Comments
If you want to resolve paths for |
There is already a
This config is working fine when with the |
Hi @rondonjon, I am interested in this problem, could you please provide a repository to reproduce this? In my case, it seems that postcss works fine with the |
Thanks @await-ovo! Here you go: https://gitlab.com/rondonjon/tsup-postcss-reproduction While setting this up I noticed that the problem only occurs in a yarn monorepo. But then it is fully reproducible: Test base
Style output with tsup and Expected result: body{padding:0;margin:0}html{background:red} Style output with tsup and Expected result: "use strict";(()=>{var r=`@import "./b.css";
html {
background: red;
}
`;alert(r);})(); |
Currently tsup search The temporary solution is add a I think tsup should search for postcss.config.js in the root of the project directory like vite does |
@await-ovo, thanks again, this is really helpful, and working around the issue is good enough for me at the moment. Out of curiosity, could you explain why this only affects the |
i think esbuild itself will resolve @import in css files with css loader~ |
What is your take on this @egoist ? tsup is resolving the location of the It seems arguable which resolution makes more sense (based on the location of the source file or on the tsup/project root), personally I tend towards the tsup/project root, but I think the resolution should be consistent across all loaders. |
🎉 This issue has been resolved in version 6.6.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
#743 has requested support CSS inlining as an alternative to generating additional output files.
The suggested solution was to set the
.css
loader totext
, which wasn't working initially but has been fixed in tsup 6.3.0.While the contents are now "inlined", it seems that they are no longer preprocessed by
postcss
, as one would expect from "CSS inlining".With the default settings, tsup generates an external CSS of more than 150 KB in size ...
... but after setting the
.css
loader totext
, I am now getting a very short (inlined) CSS snippet which still contains imports thatpostcss
should have resolved:Actually I find this behavior quite logical and consistent and would propose to leave it just how it is. If the content were preprocessed by
postcss
, the term (plain)"text"
would be misleading. But that obviously doesn't solve the original request.Could we have a new loader option
inline-css
to make this more explicit and meet the original request?Or, more generically, would it make sense to split these configs into at least two parameters, "loading" (inlined vs. extra file) and "transformation" (e.g. typescript, svelte, css)?
The text was updated successfully, but these errors were encountered: