PhoenixMountable.Assets.Host (PhoenixMountable v0.2.1)

Copy Markdown View Source

The host's own asset pipeline.

For libraries whose templates are styled by the host's Tailwind and whose JavaScript hooks the host registers. The library serves no files: its LiveViews usually render inside the host's root layout (layout: :host), which already loads the host's CSS and JavaScript.

use PhoenixMountable,
  otp_app: :my_lib,
  macro: :my_lib,
  layout: :host,
  assets: {PhoenixMountable.Assets.Host, []}

The host tells Tailwind to scan the library's templates. With Tailwind v4 (Phoenix 1.8), in assets/css/app.css:

@source "../../deps/my_lib";

With Tailwind v3 (Phoenix 1.7), in assets/tailwind.config.js:

content: [
  // ...
  "../deps/my_lib/**/*.*ex"
]

tailwind_source/2 returns the right line, and PhoenixMountable.Igniter.add_tailwind_source/2 adds it for the host.

Options

  • :entries — host asset paths to expose as entries, for a library that renders its own layout but loads the host's files, such as [css: "/assets/css/app.css", js: "/assets/js/app.js"]. URLs go through the endpoint's static path, so they carry the digest in production. Defaults to [].

Summary

Functions

The line that makes the host's Tailwind scan a library's templates.

Functions

tailwind_source(otp_app, atom)

@spec tailwind_source(atom(), :v3 | :v4) :: String.t()

The line that makes the host's Tailwind scan a library's templates.

version is :v4 (a CSS @source directive, relative to assets/css/app.css) or :v3 (a content glob, relative to assets/tailwind.config.js).