-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
[v4] Something has broken since alpha.15, causing imports in CSS files and vite URL imports to not work #14558
Comments
Hey @bitofbreeze! The first error you posted there suggest that you're trying to load the CSS file like a JavaScript file. Regarding the other question: Do you mind sharing the repro as a small minimal setup in a repo on GitHub maybe or in any other way so we can take a closer look? |
@philipp-spiess Yes absolutely. Here is a repo with repros of both issues I encountered in alpha.25 that worked perfectly in alpha.15: https://github.com/bitofbreeze/tailwind-v4 Please search for "Begin Issue" to find both issues. You can run the code by doing |
Thanks a ton for this! The handling of |
Part-of #14558 After handling `@import` of stylesheets in core, we can no longer gate out features based on finding a specific sequence in the input CSS, as this string will not contain contents from other stylesheets. So, consider the following input CSS: ```css @import "tailwindcsss"; @import "./styles.css"; ``` We can't opt-out of the traversal to search for `@apply` based on it because it, of course, does not contain the contents of `./styles.css` yet. --------- Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
Probable related problem here with the style-url import. Nailed it down to the alpha-22 release. My question in Discord was: From alpha-22 on my remix-vite-tailwind-vite-plugin-v4 app (early developing stage) breaks with some postcss error "unknown word". Probably cause of tailwind changed to be a preprocessor and postcss of course does not expect "export styles ... " My question: From alpha-22 on i need to import my tailwind styles file with a side effect import to keep the build (dev - prod not tested) working. |
I think we're having a related problem, this minimal example stopped working as of import { compile } from "tailwindcss";
import theme from "tailwindcss/theme.css?raw";
import utilities from "./utilities.css?raw";
interface Compiler {
build: (candidates: string[]) => string;
}
export async function createCompiler(): Promise<Compiler> {
console.log({ theme, utilities });
return compile(`
@media theme(reference inline) {
${theme}
}
${utilities}
@tailwind utilities;
`);
} We're using static asset imports to bake CSS into a custom compiler at build time. With |
I can only speak in relation to nuxt/ui#2263, but I would like to document it anyway. The issue we were facing was related to upgrading from Again, this might not be directly related to this issue. But still, the output we were given was about vite import issues, and fixing up some |
Fixes: #14558 This PR fixes an issue where our Vite plugin would crash when trying to load stylesheets via certain static asset query parameters: ```ts import raw from './style.css?raw' import url from './style.css?url' ``` The proper behavior for our extension is to _not touch these file at all_. The `?raw` identifier should never transform anything and the `?url` one will emit a module which points to the asset URL. However, if that URL is loaded as a stylesheet, another transform hook is called and the file is properly transformed. I verified this in the Vite setup and have added an integration test ensuring these two features work as expected. I've also greatly reduced the complexity of the Vite playground to make it easier to set up examples like this in the future.
Hey folks! Just wanted to let you know that we've landed a fix for the |
Just gave it a try and still getting issues:
Let me know if a repro is needed again. Maybe just upgrading the previous one would show the issue, but I haven't tried yet. Thanks for the quick turnaround. |
@bitofbreeze The repro you provided seems to work fine with ![]() The stack trace also doesn't seem to have Tailwind CSS in it so a repro would be greatly appreciated, thank you! |
Oh I had an absolute import that was causing it. Thanks for letting me know, that fixed it! |
What version of Tailwind CSS are you using?
v4.0.0-alpha.25
What build tool (or framework if it abstracts the build tool) are you using?
vite 5.4.8
What version of Node.js are you using?
bun 1.1.27
What browser are you using?
Chrome
What operating system are you using?
macOS
Reproduction URL
Unfortunately Stackblitz doesn't support creating a repro since it can't run the tailwind wasm module used in the @tailwindcss/vite plugin.
Describe your issue
With v4.0.0-alpha.15, I can have a css file that does:
and use that stylesheet as a vite URL import:
However, when I just upgrade to v4.0.0-alpha.25, I get
Uncaught SyntaxError: The requested module '/app/root.css?url' does not provide an export named 'default'
because the vite URL imports have broken.If I just import normally without the URL suffix (
import "./root.css";
),That works back on v4.0.0-alpha.15.
Please let me know if I can provide more info, or if instead of Stackblitz, there is another provider that does support wasm.
The text was updated successfully, but these errors were encountered: