BunBundle installs and runs Bun as an asset bundler for Elixir web apps.
It vendors a small JS bundler taken from its counterpart, the Ruby gem bun_bun_bundle, and runs it under Bun. Bun ships Lightning CSS built in. That covers glob imports, nesting, autoprefixing, and minification without a separate CSS toolchain.
Configuration
config :bun_bundle, version: "1.4.2"All bundler configuration lives in config/bun.json at your project root.
Bun reads it directly. BunBundle does not translate config. The same format
is used by the Ruby and Crystal ports.
Global options
:version. The expected Bun version.:version_check. Whether to warn on version drift at boot. Defaults totrue.:path. Override the path to the Bun binary. By default it is downloaded to_build/bun-<target>.
Usage in Phoenix
# config/dev.exs
config :my_app, MyAppWeb.Endpoint,
watchers: [
bun: {BunBundle, :install_and_run, [~w(--dev)]}
]
# mix.exs aliases
"assets.setup": ["bun.install --if-missing"],
"assets.build": ["bun"],
"assets.deploy": ["bun --prod", "phx.digest"]
Summary
Functions
Returns the path to the Bun executable.
Returns the version of the installed Bun binary.
Returns the configured Bun version.
Downloads the configured Bun release and installs it under _build/.
Installs Bun if missing, then runs the bundler with args.
Returns the latest Bun version known to this package release.
Runs Bun against the vendored bundler with the given args.
Returns the path to the vendored bake.js entry point.
Functions
Returns the path to the Bun executable.
The executable may not exist yet if install/0 has not been run.
Returns the version of the installed Bun binary.
Returns {:ok, version_string} on success. Returns :error if Bun is not
installed or does not respond.
Returns the configured Bun version.
Downloads the configured Bun release and installs it under _build/.
Installs Bun if missing, then runs the bundler with args.
This is the function to call from a Phoenix :watchers list.
Returns the latest Bun version known to this package release.
Runs Bun against the vendored bundler with the given args.
Output is streamed to stdio. Returns the exit status.
Returns the path to the vendored bake.js entry point.