How to use tailwindcss/vite with vite 8 #19624
-
|
How to use tailwindcss/vite with vite 8 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Warning Until a stable release is available, I wouldn't build on Vite 8, as you can run into many compatibility issues while numerous dependencies don't officially support it yet - even a single small breaking change in the API can be enough. How to install Vite 8 with TailwindCSS v4Vite 8 is still in beta and not stable. Until a stable release is available, it's not customary to provide official support for it. For the beta, you can force-attach plugins with incompatible versions at your own risk, like this: package.json {
"dependencies": {
"vite": "8.0.0-beta.11",
"tailwindcss": "^4",
"@tailwindcss/vite": "^4"
},
"overrides": {
"@tailwindcss/vite": {
"vite": "8.0.0-beta.11"
}
}
}vite.config.ts import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [
tailwindcss(),
],
})In theory, there shouldn't be many changes, but if there are significant changes in the Vite API, it can break package.json {
"dependencies": {
"vite": "8.0.0-beta.11",
"postcss": "^8",
"tailwindcss": "^4",
"@tailwindcss/postcss": "^4"
},
}vite.config.ts import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/postcss'
export default defineConfig({
css: {
postcss: {
plugins: [
tailwindcss(),
],
},
},
})Vite 8 breaking change: use LightningCSS instead of ESBuildAn important breaking change is that TailwindCSS uses LightningCSS under the hood, while Vite 8 also uses LightningCSS but with a different configuration (LightningCSS is configurable). TailwindCSS will have to address this issue and make its LightningCSS settings exportable so they can be applied in Vite. Until then, it's recommended to stick with the stable release.
vite.config.ts import { defineConfig } from "vite";
import tailwindcss from "@tailwindcss/vite";
export default defineConfig({
build: {
cssMinify: 'esbuild', // default: 'lightningcss'
},
plugins: [
tailwindcss(),
],
}); |
Beta Was this translation helpful? Give feedback.
Warning
Until a stable release is available, I wouldn't build on Vite 8, as you can run into many compatibility issues while numerous dependencies don't officially support it yet - even a single small breaking change in the API can be enough.
How to install Vite 8 with TailwindCSS v4
Vite 8 is still in beta and not stable. Until a stable release is available, it's not customary to provide official support for it. For the beta, you can force-attach plugins with incompatible versions at your own risk, like this:
package.json
{ "dependencies": { "vite": "8.0.0-beta.11", "tailwindcss": "^4", "@tailwindcss/vite": "^4" }, "overr…