Skip to content

buildTrunkPackage: add support for tailwindcss 4#990

Merged
ipetkov merged 6 commits intoipetkov:masterfrom
deadbaed:trunk-tailwind
Mar 24, 2026
Merged

buildTrunkPackage: add support for tailwindcss 4#990
ipetkov merged 6 commits intoipetkov:masterfrom
deadbaed:trunk-tailwind

Conversation

@deadbaed
Copy link
Copy Markdown
Contributor

Trunk supports generating css with tailwind for assets using rel="tailwind-css" in the index.html file (see trunk documentation).

Output of the tailwind CLI used to extract the version number (there is noflag to get the version, using the --help flag instead):

phil@m1ir:~/ > nix-shell -p tailwindcss_4

[nix-shell:~]$ tailwindcss --help
≈ tailwindcss v4.1.18

Usage:
  tailwindcss [--input input.css] [--output output.css] [--watch] [options…]

Options:
  -i, --input ················· Input file
  -o, --output ················ Output file [default: `-`]
  -w, --watch[=always] ········ Watch for changes and rebuild as needed, and use `always` to keep watching when stdin is closed
  -m, --minify ················ Optimize and minify the output
      --optimize ·············· Optimize the output without minifying
      --cwd ··················· The current working directory [default: `.`]
      --map ··················· Generate a source map [default: `false`]
  -h, --help ·················· Display usage information

The env variable TRUNK_TOOLS_TAILWIND expects to have the version number without the leading v.

Motivation

I use trunk with tailwind, and it's my first time packaging a trunk app with crane. I had to add the env variables in my derivation, and saw afterwards the support for SCSS and wanted to give back upstream! Thank you for this library.

Checklist

  • added tests to verify new behavior
  • added an example template or updated an existing one
  • updated docs/API.md (or general documentation) with changes
  • updated CHANGELOG.md

For the test I duplicated the existing test trunk, removed the scss file and added tailwind, let me know if I did something wrong.

@deadbaed deadbaed force-pushed the trunk-tailwind branch 3 times, most recently from 88b7fc6 to 2a13f1e Compare March 16, 2026 20:59
Trunk supports generating css with [tailwind](https://tailwindcss.com) for assets using `rel="tailwind-css"` in the index.html file (see [trunk documentation](https://trunk-rs.github.io/trunk/guide/assets/index.html#tailwind)).

Output of the tailwind CLI used to extract the version number (there is noflag to get the version, using the `--help` flag instead):
```
phil@m1ir:~/ > nix-shell -p tailwindcss_4

[nix-shell:~]$ tailwindcss --help
≈ tailwindcss v4.1.18

Usage:
  tailwindcss [--input input.css] [--output output.css] [--watch] [options…]

[...]
```

The env variable `TRUNK_TOOLS_TAILWIND` expects to have the version
number without the leading `v`.

Callers must provide the tailwind CLI with `nativeBuildInputs`.
@deadbaed
Copy link
Copy Markdown
Contributor Author

Sorry, I forgot to fix the tests when I made the changes a couple of days ago.

Tests are fixed, and rebased from master.

@ipetkov
Copy link
Copy Markdown
Owner

ipetkov commented Mar 24, 2026

Thanks for the contribution! I tweaked the tests a bit to simplify things (and reduce how much we need to recompile) but otherwise looks good to me!

@ipetkov ipetkov enabled auto-merge (squash) March 24, 2026 00:45
@ipetkov ipetkov merged commit aed0122 into ipetkov:master Mar 24, 2026
18 checks passed
@deadbaed
Copy link
Copy Markdown
Contributor Author

My pleasure! Nice trick to patch the example to get tailwind, didn't thought of that! Cheers

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