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

@astrojs/tailwind ignores Tailwind CSS v3.3 TypeScript config #6695

Closed
1 task
phenomen opened this issue Mar 28, 2023 · 17 comments · Fixed by #6724
Closed
1 task

@astrojs/tailwind ignores Tailwind CSS v3.3 TypeScript config #6695

phenomen opened this issue Mar 28, 2023 · 17 comments · Fixed by #6724
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)

Comments

@phenomen
Copy link

phenomen commented Mar 28, 2023

What version of astro are you using?

2.1.8

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

pnpm

Describe the Bug

When I use Tailwind CSS v3.3 TypeScript config file tailwind.config.ts, Astro ignores it and uses default config instead.

Reference: https://tailwindcss.com/blog/tailwindcss-v3-3#esm-and-typescript-support

I think you just need to bump Tailwind dependency to use updated resolveConfig.

Participation

  • I am willing to submit a pull request for this issue.
@matthewp matthewp added the - P2: nice to have Not breaking anything but nice to have (priority) label Mar 28, 2023
@matthewp
Copy link
Contributor

Thanks @phenomen, would accept a PR if you wanted to fix this.

@alf5
Copy link

alf5 commented Mar 29, 2023

it looks like tailwind 3.3 is already picked up by @astrojs/tailwind (either new project or pnpm upgrade)
but fails to load tailwind config file
Maybe this is as easy as getting @proload/core to use its typescript plugin - @proload/plugin-typescript ?

@Princesseuh
Copy link
Member

I wonder if using proload is the best solution for loading the config. I'd expect Tailwind to provide something for that

@juliusmarminge
Copy link
Contributor

juliusmarminge commented Mar 29, 2023

I wonder if using proload is the best solution for loading the config. I'd expect Tailwind to provide something for that

They have. tailwindcss/loadConfig: https://github.com/tailwindlabs/tailwindcss/blob/master/src/lib/load-config.ts

We just shipped support for this in prettier-plugin-tailwindcss: tailwindlabs/prettier-plugin-tailwindcss#137

@FinnDore
Copy link

I wonder if using proload is the best solution for loading the config. I'd expect Tailwind to provide something for that

I think so https://github.com/tailwindlabs/tailwindcss/blob/master/src/lib/load-config.ts

can be imported like so:

import loadConfig from 'tailwindcss/loadConfig'

@FinnDore
Copy link

Gonna try make a pr now

@FinnDore
Copy link

So ive got it kind of working. Just struggling to get custom colors to load in the example for some reason
image

@FinnDore
Copy link

ah it was simply a questionable skill issue, for 34 minuites the idea that bg needs to be applied to t3-purple-100 for it to change the bg color had escaped my mind.... we have a working TS config!

image

just gonna clean up my code and then work out if this is still needed. If anyone has any ideas do tell me.
image

@juliusmarminge
Copy link
Contributor

Tailwind does something similar so i think you need it https://github.com/tailwindlabs/prettier-plugin-tailwindcss/blob/70ea7aa55d5ecc1b9202273b4c4deb84c4d8c979/src/index.js#L180

@FinnDore
Copy link

Currently its all working locally ( including the build ) but for some reason in ci the build is failing and i cant work out why. If anyone has any ideas lmk :)

@FinnDore
Copy link

So i got it all working however some of the not explicitly tailwind tests kept failing so ive given up for now. if some hero wants to take this on feel free to fork my repo or start from scratch. But i was 95% there i rekon.

Its worth noting you can remove this integration and simply create a postcss config inside you astro project to make use of tialwind 3.3.0 rn.

@TomPichaud
Copy link
Contributor

@FinnDore Please try my fix, it should work nicely.
Also, you shouldn't bother with the tests failing if they are not related, they should still merge it.

@FinnDore
Copy link

FinnDore commented Apr 2, 2023

Guess you have already tried the fix in #6724? oh and to be clear i did break the tests but im not sure how to get them working again.

@TomPichaud
Copy link
Contributor

I've been using my fix and it does seem to work properly. I feel like this integration was doing too much redundant work.
Now it just setup postcss + base css import and it let tailwind handle the rest, as it should.

@azan-n
Copy link

azan-n commented May 4, 2023

Would love to have this fixed. This would give me ESM support in the tailwind config which would allow me to bring in design tokens from Style Dictionary.

@Princesseuh
Copy link
Member

Princesseuh commented Jun 8, 2023

Bumping the priority on this as more and more people are using ESM / TS configs with Tailwind and we get many confused users both in other issues and in our Discord

@Princesseuh Princesseuh added - P4: important Violate documented behavior or significantly impacts performance (priority) and removed - P2: nice to have Not breaking anything but nice to have (priority) labels Jun 8, 2023
@TomPichaud
Copy link
Contributor

TomPichaud commented Jun 8, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)
Projects
None yet
8 participants