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

build: replace node/npm with tailwindcss cli (v3.4.4) #50

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cjshearer
Copy link
Owner

@cjshearer cjshearer commented Jun 26, 2024

This is a test for replacing node/npm with the standalone tailwindcss cli, using the new css.Tailwind feature introduced in hugo 0.128.0. Since css.Tailwind feature is intended for tailwind v4, which does not yet have a --config option, I cannot directly use module mounts to mount a tailwind.config.js file provided by a theme/module. However, this PR contains a workaround where we use the HUGO_FILE_TAILWIND_CONFIG_JS provided by hugo to find the theme's tailwind.config.js. By having the exampleSite (or other calling module) use a different name for the theme (e.g. tailwind.config.mjs), which is still recognized by tailwindcss, but is not recognized by hugo, the calling site can use a thin wrapper which calls out to the theme's tailwind config.

An interesting side-effect of this is that consumers of this theme will be able to override/extend the tailwind configuration without vendoring, which is actually pretty cool!

image

@cjshearer cjshearer changed the title build: wip remove node build: replace node/npm with tailwindcss cli Jun 26, 2024
@cjshearer cjshearer changed the title build: replace node/npm with tailwindcss cli build: replace node/npm with tailwindcss cli (v3.4.4) Jun 26, 2024
@cjshearer
Copy link
Owner Author

cjshearer commented Jun 26, 2024

One consideration with this method is that installing multiple themes, each with different tailwind.config.js files, is almost certain to break. Only the first tailwind config that gets resolved will be supplied, which makes this very brittle.

If I could refactor my tailwindcss stuff to be compatible with the v4 alpha (in other words, implement a subset of tailwindcss/typography within main.css) then I wouldn't need a config, I could use v4, and I could import multiple (tailwind v4 compatible) themes.

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.

None yet

1 participant