If the automatic upgrade fails to migrate your CSS class names (common when using plugins without a JS toolchain), you can perform a manual migration using a temporary JavaScript environment.
- Prepare Git: Add
/node_modules to your .gitignore. - Setup Node Environment: Create a
package.json in your root. You must include tailwindcss (v3.4.17 or similar) and any plugins referenced in your tailwind.config.js (e.g., @tailwindcss/forms). - Install Dependencies: Run
npm install or yarn install. - Adjust Config Paths: In
config/tailwind.config.js, add an extra dot . to the start of all paths in the content array to make them relative to the config file (e.g., ../app/views/... becomes .../app/views/...). - Run Upgrader: Run
bin/rails tailwindcss:upgrade. - Cleanup:
- Remove unnecessary modules from
package.json. - If you don't need a JS toolchain, delete
package.json, node_modules/, and the lockfile, then remove /node_modules from .gitignore. - Remove any
@plugin directives from your CSS file. - Revert the
content paths in config/tailwind.config.js to be relative to the application root.
{
"name": "app_name",
"version": "1.0.0",
"dependencies": {
"tailwindcss": "^3.4.17", // Mandatory!!
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/forms": "^0.5.10",
"@tailwindcss/typography": "^0.5.16"
}
}
// config/tailwind.config.js
// Temporarily add an extra '.' to paths during upgrade
content: [
'../public/*.html',
'../app/helpers/**/*.rb',
'../app/javascript/**/*.js',
'../app/views/**/*.{erb,haml,html,slim}'
],