Sayfa.Tailwind (Sayfa v0.5.0)

Copy Markdown View Source

TailwindCSS integration for compiling theme styles.

Uses the tailwind hex package to automatically download and run the TailwindCSS CLI. The correct platform-specific binary is downloaded and cached on first use — no manual installation required.

The input CSS is resolved through the theme chain — custom theme CSS takes priority, falling back to the default theme's assets/css/main.css.

Examples

config = Sayfa.Config.resolve()
Sayfa.Tailwind.compile(config, "dist")

Summary

Functions

Compiles TailwindCSS for the site.

Resolves the input CSS file path through the theme chain.

Functions

compile(config, output_dir, opts \\ [])

@spec compile(map(), String.t(), keyword()) ::
  :ok | :skipped | {:error, {:tailwind_failed, non_neg_integer()}}

Compiles TailwindCSS for the site.

Finds the input CSS through the theme chain, then runs the tailwindcss CLI (auto-downloading on first use) to produce a minified CSS file at <output_dir>/assets/css/main.css.

Returns :ok on success, or :skipped if no input CSS is found in the theme chain.

Options

  • :minify — whether to minify the output (default: true)

Examples

Sayfa.Tailwind.compile(config, "dist")
#=> :ok

Sayfa.Tailwind.compile(config, "dist", minify: false)
#=> :ok

resolve_input_css(config)

@spec resolve_input_css(map()) :: String.t() | nil

Resolves the input CSS file path through the theme chain.

Walks from custom theme → parent theme → default theme, returning the first assets/css/main.css that exists.

Returns nil if no input CSS is found.

Examples

iex> config = %{theme: "default", theme_parent: "default"}
iex> path = Sayfa.Tailwind.resolve_input_css(config)
iex> is_binary(path) or is_nil(path)
true