Skip to content

Pass the CSS entrypoint to canonicalize as --css - #10

Merged
aptinio merged 1 commit into
aptinio:mainfrom
leoherbie:fix/canonicalize-css-flag
Sep 30, 2026
Merged

aptinio merged 1 commit into
aptinio:mainfrom
leoherbie:fix/canonicalize-css-flag

Conversation

@leoherbie

Copy link
Copy Markdown
Contributor

tailwindcss canonicalize names its CSS entrypoint --css. It has done so since the subcommand was introduced (tailwindlabs/tailwindcss#19783) and has never accepted --input — it drops the flag silently and exits 0. CanonicalTailwind.Config.resolve_input/2 emits --input=<path> on both branches, so the entrypoint never reaches the CLI and every canonicalization runs against the stock @import "tailwindcss" design system instead of the project's — whether the path came from canonical_tailwind: [input: ...] or was discovered in a tailwind profile's args.

That is the same symptom v0.3.1 fixed for the split --input path form ("canonicalization ran without the project's @theme and plugins"): the path is now found, but it is still handed over under a flag the CLI ignores, so the theme stays out of reach through every path.

What it looks like

Our assets/css/app.css drops the default sm breakpoint and redefines sm as a max-width variant:

@theme { --breakpoint-sm: initial; }
@custom-variant sm (@media (width <= 40rem));

With that entrypoint, min-[40rem]: is a min-width query and sm: is a max-width one — not spellings of each other. mix format rewrote

<div class="min-[40rem]:flex p-4">

to class="p-4 sm:flex", inverting the breakpoint. Running the pinned CLI by hand:

$ printf 'min-[40rem]:flex p-4\n' | tailwindcss canonicalize --stream --input=assets/css/app.css
p-4 sm:flex
$ printf 'min-[40rem]:flex p-4\n' | tailwindcss canonicalize --stream --css=assets/css/app.css
p-4 min-[40rem]:flex

canonicalize --help on 4.3.3 lists --css, --format, --stream, -h and nothing else.

The change

resolve_input/2 and the two find_profile_input/1 head clauses emit --css= instead of --input=. The profile's entrypoint still arrives spelled --input, because that is the flag tailwindcss takes when building — only the flag handed to canonicalize changes. Since canonicalize has taken --css for its whole existence, this is safe across the supported range rather than version-dependent.

Why the suite did not catch it

test/fixtures/input.css and test/fixtures/other.css are both stock @import "tailwindcss", under which a dropped --input and an honoured --css produce byte-identical output — so the tests could only assert the argv, which was self-consistently wrong. This adds test/fixtures/themed.css with the @theme/@custom-variant above and a test that canonicalizes min-[40rem]:flex p-4 through it; collapsing to sm:flex now fails the suite. Green against both the supported floor (4.2.2) and the current CLI (4.3.3).

Happy to drop the CHANGELOG entry or reword it if you'd rather keep that yours.

`tailwindcss canonicalize` names its entrypoint `--css`. It has done so since
the subcommand was introduced (tailwindlabs/tailwindcss#19783) and has never
accepted `--input`, which it drops silently and exits 0 on. So every
canonicalization ran against the stock `@import "tailwindcss"` design system
instead of the project's, regardless of whether the path came from
`canonical_tailwind: [input: ...]` or was discovered in a tailwind profile's
`args`.

That is the symptom v0.3.1 fixed for the split `--input path` form: the path is
now found, but it was still handed over under a flag the CLI ignores, so the
`@theme` and plugins stayed out of reach through every path.

The profile's entrypoint still arrives spelled `--input`, because that is the
flag `tailwindcss` takes when *building*; only the flag handed to `canonicalize`
changes.

The existing fixtures are both stock `@import "tailwindcss"`, under which a
dropped `--input` and an honoured `--css` produce identical output, which is why
the suite could only assert the argv. test/fixtures/themed.css drops the `sm`
breakpoint and redefines `sm` as a max-width variant, so `min-[40rem]:flex`
collapsing to `sm:flex` now fails the suite rather than passing it. Green
against both the supported floor (4.2.2) and the current CLI (4.3.3).
@aptinio
aptinio merged commit eed8e2e into aptinio:main Sep 30, 2026
2 checks passed
@aptinio

aptinio commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Thanks for catching this and adding the regression test, @leoherbie. Merged!

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