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

feat: add tailwind.config.ts support #483

Merged
merged 6 commits into from
Jul 11, 2022

Conversation

harlan-zw
Copy link
Contributor

@harlan-zw harlan-zw commented May 26, 2022

πŸ”— Linked issue

n/a

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This exists for two reasons:

  • Nuxt v3 is fully typescript, .js files are out of place
  • Tailwind now ships types

This change introduces a way to define the config in typescript. While technically you could have typescript working if you provided your own configPath, it wasn't intuitive.

The changes are fairly minimal as the requireModule uses jiti already behind the scenes. I've documented the code for other nuances.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

package.json Outdated Show resolved Hide resolved
src/tailwind.config.ts Outdated Show resolved Hide resolved
@atinux
Copy link
Collaborator

atinux commented Jun 22, 2022

Thank you @harlan-zw

I am not 100% sure about supporting .ts since it is not supported by TailwindCSS officially.

From what I see, when running npx tailwindcss init, they add the types with a comment now:

/** @type {import('tailwindcss').Config} */
module.exports = {
  // ...
}

What do you think of it?

@Tahul
Copy link
Contributor

Tahul commented Jul 1, 2022

I would love to see this PR happen, I have the same feeling as @harlan-zw, seeing a .js file with module.exports syntax feels wrong!

Tailwind supports configuration typing via JSDoc type hints, but I think TypeScript looks way more natural in a Nuxt 3 project.

@harlan-zw
Copy link
Contributor Author

harlan-zw commented Jul 11, 2022

I've removed the decorator from the PR to simplify the changes, swapped the types to use the official tailwind ones and made the doc clearer around the conventions.

Given that the module already supports typescript without this change, I think it's worthwhile documenting it for users and making it slightly easier for them if this is their preference.

I also think it's a matter of time before tailwind has a typescript config.

I'll leave it with you @atinux, happy either way

@atinux
Copy link
Collaborator

atinux commented Jul 11, 2022

Much cleaner! Will merge and release thank you @harlan-zw

PS: nice new profile picture BTW!

@atinux atinux merged commit 26aebc2 into nuxt-modules:main Jul 11, 2022
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.

4 participants