Updating TailwindCSS
Info
This guide outlines how to update TailwindCSS in Hyvä projects, focusing on versions after v1.1. If you're using Hyvä with TailwindCSS v2, refer to the update steps for release 1.2.0 first.
Understanding Updates
Before updating, review the TailwindCSS changelog to understand the changes introduced in the new version.
Prerequisites
- Node.js: Ensure you have Node.js version 16 or higher installed (check with
node -v
).
How to update
- Install the update: Run
npm install tailwindcss@latest
in your theme's directory. You can replace@latest
with a specific version for more 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 Browserlist config: In your
package.json
, add the following: For more information, refer to the using browserlist docs.
- Uninstall Autoprefixer: Run
- Update Optional Plugins (Optional): You can update optional plugins like
@tailwindcss/forms
and@tailwindcss/typography
similarly: Important: While these plugins are less likely to introduce new CSS properties, reviewing their changelogs before updating is still recommended.
Updating the Configuration
This section explains situations where updating the configuration might be necessary.
Adding tailwind.config.js
merging
If you want to enable tailwind.config.js
merging, please checkout the dedicated documentation on Module tailwind.config.js merging (Note: This feature was introduced in Hyvä 1.1.14).
Update the config with the Default Theme version
When upgrading to a new Hyvä version, the upgrade documentation might highlight specific changes needed in your tailwind.config.js
.
These changes could involve adding, replacing, or removing configuration entries.
Look for sections titled New tailwind.config.js entry within the upgrade documentation
(as seen in the 1.3.0 upgrading to).