1

I'm following the Vite plugin documentation, but I'm running into an error because of the new Vite 8.

I'm creating a new project generated with the new 8.x version, then running it:

npm install tailwindcss @tailwindcss/vite
Found: [email protected]
node_modules/vite
  dev vite@"^8.0.0" from the root project

Could not resolve dependency:
peer vite@"^5.2.0 || ^6 || ^7" from @tailwindcss/[email protected]
node_modules/@tailwindcss/vite
  @tailwindcss/vite@"*" from the root project

How can I still use it with Vite 8 and the @tailwindcss/vite plugin?

1 Answer 1

4

From v4.2.2 onward

On March 12, 2026, Vite 8 was officially released.

From v4.2.2 released on March 18, 2026, official support for Vite 8 has been introduced, among other improvements, so you only need to start with v4.2.2.

package.json

{
  "dependencies": {
    "vite": "^8",
    "tailwindcss": "^4.2.2",
    "@tailwindcss/vite": "^4.2.2"
  },
}

vite.config.ts

import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'

export default defineConfig({
  plugins: [
    tailwindcss(),
  ],
})

v4.2.1 or earlier versions

Vite 8 with @tailwindcss/vite

I haven't verified it, but if the Vite API changes, the behavior of @tailwindcss/vite may change, become unpredictable, or break. For that reason, I'd treat it with some caution. In practice, however, it's the same installation step mentioned in the documentation, with one small override using a forced install to push dependencies that aren't compatible with Vite 8 alongside Vite 8.

package.json

{
  "dependencies": {
    "vite": "^8",
    "tailwindcss": "^4",
    "@tailwindcss/vite": "^4"
  },
  "overrides": {
    "@tailwindcss/vite": {
      "vite": "^8"
    }
  }
}

vite.config.ts

import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'

export default defineConfig({
  plugins: [
    tailwindcss(),
  ],
})

References:

Vite 8 with @tailwindcss/postcss

The Vite plugin is much more efficient, but in case of API breakages, @tailwindcss/postcss can be used as a fallback.

package.json

{
  "dependencies": {
    "vite": "^8",
    "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(),
      ],
    },
  },
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.