mix phoenix_bun_assets.install (PhoenixBunAssets v0.1.0)

Copy Markdown View Source

Installs the change-detecting Bun asset builder into a Phoenix app.

Example

mix igniter.install phoenix_bun_assets

This installer bootstraps a complete Bun + TypeScript asset pipeline, replacing the default esbuild/tailwind Mix tasks. It:

  • scaffolds the assets/ project — build.ts (the deterministic, change-detecting build script), package.json, tsconfig.json, tsconfig.hooks.json, .gitignore, js/app.ts, and css/app.css — creating each file only if it does not already exist,
  • configures the Phoenix endpoint watchers to run build.ts watch in dev,
  • ensures the live_reload patterns watch priv/static/**/*.{js,css,...},
  • adds assets.build / assets.deploy Mix aliases,
  • ignores the generated assets/.build-stage/ staging dir.

Any file that already exists in the target project is left untouched, so it is safe to run against a project that already has some of these files. The generated build.ts targets whatever entry points already exist — an existing js/app.ts or js/app.js (and css/app.css) is reused instead of scaffolding a competing one — so a standard Phoenix app builds without manual edits.

Bun binary

By default the installer adds the :bun dependency, which downloads and manages the bun binary for you (via mix bun.install). If you already provide bun another way — mise, system package manager, a Docker base image, asdf, etc. — pass --bun system and the installer will set up the watcher and aliases to a bun executable on your PATH instead, adding no dependency and no :bun config.

Tailwind

Pass --tailwind to enable Tailwind CSS v4 compilation through Bun's bundler (via the bun-plugin-tailwind plugin). The build script is built to load the plugin, and the installer prints the bun add command for the required npm packages.

Options

  • --bun - how bun is provided: managed (default, adds the :bun dep and manages the binary) or system (assumes bun is already on your PATH).
  • --bun-version - the bun version to pin in config. Only used with --bun managed. Defaults to a recent stable.
  • --tailwind - enable Tailwind CSS v4 compilation through Bun. Defaults to false.
  • --install-deps - after installing, run bun add in assets/ to fetch the npm packages (currently only Tailwind's). Off by default; when off, the installer just prints the bun add command for you to run yourself.