DEV Community

thomasvanholder
thomasvanholder

Posted on

7 1

How to upgrade Tailwind 2 to Tailwind 3

In package.json file, verify your current installed tailwind version. Find tailwind's complete upgrade guide, including all minor changes here.

This tutorial has as starting point:

  • Tailwind 2.2.16

  1. Upgrade tailwind
  2. Upgrade typography package
  3. Upgrade forms package
  4. Upgrade autoprefixer package
  5. Upgrade postcss package
  6. Remove aspect-ratio package
  7. Replace purge option with content
  8. Remove dark mode config

1. Upgrade tailwind

yarn upgrade tailwindcss --latest
Enter fullscreen mode Exit fullscreen mode

2. Upgrade typography package

yarn upgrade @tailwindcss/typography --latest
Enter fullscreen mode Exit fullscreen mode

3. Upgrade forms package

yarn upgrade @tailwindcss/forms --latest
Enter fullscreen mode Exit fullscreen mode

4. Upgrade autoprefixer package

yarn upgrade autoprefixer --latest
Enter fullscreen mode Exit fullscreen mode

5. Upgrade postcss package

yarn upgrade postcss --latest
Enter fullscreen mode Exit fullscreen mode

6. Remove aspect-ratio package

Tailwind 3 comes with native aspect-ratio (7:42). This implies that the package.json can be slimmed down by removing the aspect ratio package if you had it installed.

yarn remove @tailwindcss/aspect-ratio
Enter fullscreen mode Exit fullscreen mode

In the tailwind.config.js file, remove aspect-ratio from the plugins.

require('@tailwindcss/aspect-ratio'),
Enter fullscreen mode Exit fullscreen mode

7. Replace purge option with content

If after compiling the CSS, you see the warning message:
The "purge"/"content" options have changed in Tailwind CSS v3.0.

Replace the purge option in tailwind.config.js with content as mentioned here.

// old
module.exports = {
  purge: [...]
  ...
}

//new
module.exports = {
  content: [...]
  ...
}
Enter fullscreen mode Exit fullscreen mode

8. Remove dark mode config

In the tailwind.config.js file, remove the dark mode setting if it's value is set to false.

// old
module.exports = {
  darkMode: false,
  ...
}

//new
module.exports = {
  ...
}
Enter fullscreen mode Exit fullscreen mode

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (1)

Collapse
 
gianpaj profile image
Gianfranco P.

is there a codemode for this and all other changes? tailwindcss.com/docs/upgrade-guide

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay