---
contentId: 3499bbd1-20a6-43f0-9bb7-be1da2bb6eac
part: 12
title: "Migrating Our VitePress Blog to Tailwind CSS Version 4"
description: "A step-by-step guide on upgrading our VitePress blog to Tailwind CSS 4.0 to leverage its latest features and improvements."
github:
  branch: 12.migration-to-tailwind-css-4
date: 2025-05-08
seriesSlug: create-a-blog-with-vitepress-and-vue-js-from-scratch
---

Since the first episode of this series, **Tailwind CSS** has released a new major version, bringing numerous new features and enhancements. In this episode, we will migrate our **VitePress** blog to Tailwind CSS 4.0. This process is simpler than you might think and will enable us to utilize the latest features of **Tailwind CSS** while keeping our blog up-to-date.



> [!NOTE]
> I won't present the latest features of Tailwind CSS 4.0 in this episode. I recommend you read the [official announcement](https://tailwindcss.com/blog/tailwindcss-v4) on the Tailwind CSS blog.



## Upgrading dependencies

First, we need to upgrade our dependencies. To do this, I love using [taze](https://github.com/antfu-collective/taze), but since we are only updating **Tailwind CSS**, we can do it manually. Open your `package.json` file and update the following dependencies:

```json [package.json]
{
  "devDependencies": {
    "tailwindcss": "^4.1.5", // [!code ++]
    "@tailwindcss/vite": "^4.1.5", // [!code ++]
    "autoprefixer": "^10.4.20", // [!code --]
    "postcss": "^8.5.1" // [!code --]
  }
}
```

Then, run the following command to install the new dependencies:

```bash [terminal]
pnpm install
```

There are multiple things to note with this change. First, there is a new dependency called `@tailwindcss/vite`, which is the new **Vite** plugin for Tailwind CSS, simplifying the installation process. Additionally, the `autoprefixer` and `postcss` dependencies are now unnecessary.

This means that the `postcss.config.cjs` file can be safely removed, as Tailwind CSS now relies on **Vite** for CSS processing. This change enhances both performance and developer experience, one of the best features of this new version.

## Using the new Vite plugin

A new Vite plugin means we need to update our VitePress configuration to use it. Open your `.vitepress/config.mts` file and update the following code:

```ts [.vitepress/config.mts]
import Tailwind from '@tailwindcss/vite'
import { defineConfig } from 'vitepress'

export default defineConfig({
  vite: {
    plugins: [
      Tailwind() // [!code ++]
    ]
  }
})
```

And that's it!

## Updating the Tailwind CSS usage

Now that we've updated our dependencies and VitePress configuration, we need to update the usage of **Tailwind CSS** in our `app.css` file. In its latest version, Tailwind CSS has moved to a CSS-based configuration, streamlining the installation process. This means we need to update our `app.css` file.

From:

```css [.vitepress/theme/common/styles/app.css]
@tailwind base;
@tailwind components;
@tailwind utilities;
```

To:

```css [.vitepress/theme/common/styles/app.css]
@import 'tailwindcss';
```

Instead of relying on custom CSS directives, we can now use the native directive `@import` to incorporate Tailwind CSS.

Then, we migrate our configuration to the new CSS-based configuration.

```css [.vitepress/theme/common/styles/app.css]
@config "../../../../tailwind.config.cjs";

@plugin "@tailwindcss/typography";

@source '../../../../src/**/*.md';
@source '../../**/*.{vue,ts}';
```

In theory, we could completely remove the current JavaScript configuration file, but since we are using the `@tailwindcss/typography` plugin, we need to keep it.



> [!NOTE]
> Adam Wathan, the creator of Tailwind CSS, [has plans for the typography plugin](https://x.com/adamwathan/status/1894776336402583835), but we do not have any details yet.



However, we can still remove the `content` and `plugins` properties from the configuration file.

```js [tailwind.config.cjs]
/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ['./src/**/*.md', './.vitepress/theme/**/*.{vue,ts}'], // [!code --]
  theme: {
    extend: {
      typography: {
        // ...
      },
    },
  },

  plugins: [require('@tailwindcss/typography')], // [!code --]
}
```

And that's it! We are now using the latest version of **Tailwind CSS** in our **VitePress** blog!

I hope you enjoyed this overview of the migration that ensures our blog stays updated to enable us to use the latest features of **Tailwind CSS**.
