Skip to content
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

Ensure upgrade tool has access to a JS config #14597

Merged
merged 5 commits into from
Oct 7, 2024

Conversation

philipp-spiess
Copy link
Member

@philipp-spiess philipp-spiess commented Oct 4, 2024

In order to properly migrate your Tailwind CSS v3 project to v4, we need access to the JavaScript configuration object. This was previously only required for template migrations, but in this PR we're making it so that this is also a prerequisite of the CSS migrations. This is because some migrations, like @apply, also need to convert candidates that to the v4 syntax and we need the full config in order to properly validate them.

In addition to requiring a JS config, we also now attempt to automatically find the right configuration file inside the current working directory. This is now matching the behavior of the Tailwind CSS v3 CLI where it will find the config automatically if it's in the current directory and called tailwind.conf.js.

@philipp-spiess philipp-spiess force-pushed the feat/upgrade-tool-auto-config branch from b94aefe to 51ef4e6 Compare October 4, 2024 14:12
@philipp-spiess philipp-spiess marked this pull request as ready for review October 4, 2024 14:12
Comment on lines -30 to -34
// Migrate the important modifier to the end of the utility
if (utility[0] === '!') {
utility = `${utility.slice(1)}!`
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this on purpose or was this a leftover from another PR? Seems unrelated to this PR at first but just checking.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was on purpose, we don't need to move the important modified at the end inside this loop anymore, now that we always have a config and always run the candidate migrations => The candidate migration will take care of this.

@philipp-spiess philipp-spiess force-pushed the feat/upgrade-tool-auto-config branch from 0ad61df to c012f15 Compare October 7, 2024 11:32
Copy link
Member

@RobinMalfait RobinMalfait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! While testing I did notice we have a bogus import still. But apart from this this seems to work as expected!

packages/@tailwindcss-upgrade/src/index.ts Outdated Show resolved Hide resolved
@philipp-spiess
Copy link
Member Author

@RobinMalfait haha whoops 🙈

@philipp-spiess philipp-spiess merged commit 7be5346 into next Oct 7, 2024
1 check passed
@philipp-spiess philipp-spiess deleted the feat/upgrade-tool-auto-config branch October 7, 2024 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants