-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add support for Tailwind 3 #54
Comments
Tailwind 4 and also UnoCSS (according to Adam) are great because they don't require any user input. The... not easiest.. But fairly sleek way to add support for TW3 is to export a import {
createResolver
} from 'astro-integration-kit'
import plugin from 'tailwindcss/plugin'
import { type Config, } from 'tailwindcss'
const { resolve } = createResolver(__dirname)
export const GalaxyTailwindContent = [
resolve('../**/*.{astro,html,js,ts,jsx,tsx,css}'),
]
export const GalaxyTailwindPlugin = () => plugin(() => {}, {
theme: {
fontFamily: {
'galaxy-display': 'Titillium Web',
'galaxy-body': 'Albert Sans',
},
},
});
export const wrapTailwindConfig = (config: Config): Config => {
if (!config.content) {
config.content = []
}
if (!config.plugins) {
config.plugins = []
}
(config.content as unknown[]).push(
...GalaxyTailwindContent,
)
config.plugins.push(GalaxyTailwindPlugin())
return config
} Then the user // tailwind.config.js
import { wrapTailwindConfig } from 'my-theme/tailwind'
export default wrapTailwindConfig([...}) // they can then pass their own config here. It would be better if you could just export a tailwind plugin. But neither TW3 plugins or extends let you add |
These are some great insights, thanks for the info!
I didn't realize that plugins could not extend import { mergeTailwindConfigs } from 'astro-theme-provider';
import configOne from 'my-theme-one/tailwind';
import configTwo from 'my-theme-two/tailwind';
export default mergeTailwindConfigs(
configOne ,
configTwo ,
{
// User config
},
) This seems like it would be a pain to code gen though. I hope support for tailwind 4 comes soon with backwards compatibility, that would be the easiest solution, just add a Vite plugin! |
I experimented with UnoCSS recently, and I think it is the best option here:
|
Astro Theme Provider could automatically support theme packages that use tailwind by adding the package's path to the
content
array inside the tailwind configurationThings to consider:
astro add
The text was updated successfully, but these errors were encountered: