-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
What version of Tailwind CSS are you using?
4.0.0-alpha.19
What build tool (or framework if it abstracts the build tool) are you using?
Vite 5.4.0
What version of Node.js are you using?
20.16.0
What browser are you using?
N/A
What operating system are you using?
Ubuntu 22.04
Reproduction URL
Let me know if you need this and how you'd like it. It works fine on Tailwind Play but fails in Vite.
Describe your issue
With a Vite config specifies "lightningcss"
as the CSS transformer:
import tailwindcss from "@tailwindcss/vite";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
export default defineConfig({
css: {
transformer: "lightningcss",
},
plugins: [react(), tailwindcss()],
});
The behaviour of the Vite plugin is undefined and buggy.
It crashes when using @apply
with class names containing characters *
or /
:
@import "tailwindcss";
@utility foo {
@apply text-3xl/tight;
}
12:44:49 PM [vite] Pre-transform error: Cannot apply unknown utility class: /
12:44:49 PM [vite] Internal server error: Cannot apply unknown utility class: /
Plugin: @tailwindcss/vite:generate:serve
File: /workspace/packages/ui/src/tailwind.css
at onInvalidCandidate (file:///workspace/node_modules/.pnpm/tailwindcss@4.0.0-alpha.19/node_modules/tailwindcss/dist/lib.mjs:6:109810)
...
It pollutes the console with warnings:
Error running vite:css on Tailwind CSS output. Skipping.
Error running vite:css on Tailwind CSS output. Skipping.
Error running vite:css on Tailwind CSS output. Skipping.
And it seems to ignore @layer base
classes.
You can work around the problem by removing the offending part of the Vite config.