-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Bump all Tailwind CSS related dependencies during upgrade #17763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This will now bump all tailwindcss-like dependencies if they exist in your package.json
try { | ||
let packageJsonPath = resolve(base, 'package.json') | ||
let packageJsonContent = await fs.readFile(packageJsonPath, 'utf-8') | ||
return packageJsonContent.includes(`"${name}":`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used quotes otherwise tailwindcss
would also match if it saw @tailwindcss/postcss
. Even though that doesn't really matter in this case.
Also, this doesn't really handle aliases at all:
"my-tailwindcss": "npm:[email protected]"
It also potentially overrides locally installed versions or symlinks:
"tailwindcss": "file:/path/to/local/version"
But give we want to work on a clean Git repo, I think this should be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, not even trying to parse the JSON file. Took this from the prettier upgrade script we had (which I replaced with this) which means that you don't have to list dependencies
, devDependenies
, optionalDependencies
, ...
info('Updating dependencies…') | ||
{ | ||
// Migrate the prettier plugin to the latest version | ||
await migratePrettierPlugin(base) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this to the array of dependencies to upgrade.
'@tailwindcss/vite', | ||
'@tailwindcss/node', | ||
'@tailwindcss/oxide', | ||
'prettier-plugin-tailwindcss', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added prettier-plugin-tailwindcss
here instead of the dedicated migratePrettierPlugin
step.
for (let dependency of [ | ||
'tailwindcss', | ||
'@tailwindcss/cli', | ||
'@tailwindcss/postcss', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PostCSS config is migrated later, which means that on v3 projects at the time of running this will result in a no-op.
This PR bumps all Tailwind CSS related dependencies when running the upgrade tool if the dependency exists in your package.json file.
E.g.: if you have
tailwindcss
and@tailwindcss/vite
in your package.json, then both will be updated to the latest version.This PR is not trying to be smart and skip updating if you are already on the latest version. It will just try and update the dependencies and your package manager will do nothing in case it was already the latest version.
Test plan
Ran this on one of my personal projects and this was the output:

Notice that I don't have
@tailwindcss/vite
logs because I am using@tailwindcss/postcss
.