Updating to Tailwind CSS v3
Info
This guide covers updating Tailwind CSS in Hyvä projects (v1.1+). If you're using Tailwind CSS v2, first follow the update steps for release 1.2.0.
Understanding Updates
Always review the Tailwind CSS changelog before updating to understand new changes.
Prerequisites
- Node.js: Ensure Node.js v16+ is installed (check with
node -v).
How to Update
- Install Tailwind CSS: Run
npm install [email protected]in your theme's directory. Replace@1.3with a specific version for precise control. - Upgrade PostCSS (Optional): If you're not already using
postcss-preset-env, follow these steps:- Uninstall Autoprefixer: Run
npm uninstall autoprefixer. - Install postcss-preset-env: Run
npm install postcss-preset-env. - Update
postcss.config.js:- Remove
require('autoprefixer'), - Add
require('postcss-preset-env'),afterrequire('tailwindcss'),
- Remove
- Add
browserslistconfig: In yourpackage.json, add: For more information, refer to the using browserlist docs.
- Uninstall Autoprefixer: Run
- Update Optional Plugins (Optional): Update optional plugins (e.g.,
@tailwindcss/forms,@tailwindcss/typography) using: Important: Although these plugins are less likely to introduce new CSS properties, always review their changelogs before updating.
Updating the Configuration
Configuration updates may be required in these situations:
Adding tailwind.config.js merging
To enable tailwind.config.js merging (introduced in Hyvä 1.1.14), refer to the dedicated documentation on Module tailwind.config.js merging.
Update with Default Theme Configuration
New Hyvä versions may require specific tailwind.config.js changes (adding, replacing, or removing entries).
Look for sections titled New tailwind.config.js entry within the upgrade documentation (as seen in the 1.3.0 upgrading to).