Runs the real tailwindcss binary over your sources and converts its
output into the class → inline-declarations map used by
PhoenixEmail.Tailwind at render time.
Works with Tailwind v3 and v4 binaries — the version is detected and both
the invocation and the CSS post-processing adapt. Normally invoked through
mix phoenix_email.tailwind.
Summary
Functions
Parses tailwind's CSS output (v3 or v4) into a class → inline-declarations map.
Finds the tailwind binary: :tailwind_bin config, the tailwind hex
package, tailwindcss in $PATH, or — as a fallback — a Tailwind
v4.3.2 CLI installed with npm into a cached
directory. New Phoenix projects ship the hex package with v4, so that is
the path most apps take.
Compiles the map and writes it to PhoenixEmail.Tailwind.map_path/0.
Functions
Parses tailwind's CSS output (v3 or v4) into a class → inline-declarations map.
Email-oriented post-processing:
- custom properties are resolved from the rule itself,
:root/universal selectors, and@propertyinitial values, then dropped; declarations with an unresolvablevar()are discarded calc()chains of*and/over numbers are evaluatedrembecomes px (x16);rgb(r g b / a)andoklch()become hex (orrgba()when translucent);color-mix(..., transparent)becomesrgba()- logical properties (
padding-inline, …) become physical pairs (ltr) - at-rule blocks (
@media,@supports) and pseudo-class selectors are skipped — variants cannot be inlined
Finds the tailwind binary: :tailwind_bin config, the tailwind hex
package, tailwindcss in $PATH, or — as a fallback — a Tailwind
v4.3.2 CLI installed with npm into a cached
directory. New Phoenix projects ship the hex package with v4, so that is
the path most apps take.
Returns {:ok, command, prefix_args, input_base_dir} — the last element
forces the generated input CSS to live next to the npm node_modules so
the CLI can resolve its imports (nil for standalone binaries).
Compiles the map and writes it to PhoenixEmail.Tailwind.map_path/0.
Options
:content- glob patterns to scan (default: the:tailwind_contentconfig key, or["lib/**/*.ex"]):config- atailwind.config.js(v3, or v4 via@config) or a CSS entry point with your@theme(v4) to use instead of the generated input (default: the:tailwind_configconfig key):output- where to write the map (default:map_path/0)
Returns {:ok, map} or {:error, reason}.