ExTauri.Sidecar behaviour (ex_tauri v0.2.0)
View SourceBehaviour and registry for the sidecar "shim" ExTauri generates at
burrito_out/desktop-<triplet> — the executable Tauri spawns to launch your
application.
ExTauri ships two built-in shims:
:phx_server(alias:dev_server, the default) — runs a dev-server command directly so hot/live reload works inside the Tauri window. The command defaults tomix phx.serverbut is configurable, so you are not tied to Phoenix:# config/config.exs — run Francis instead of Phoenix config :ex_tauri, :dev_command, ~w(mix francis.server):release— builds a standard (non-Burrito) Elixir release and execs it, exercising release boot, runtime config, and migrations.
For anything the :dev_command config can't express, implement this
behaviour and register it under a name of your choosing:
defmodule MyApp.Sidecar.Custom do
@behaviour ExTauri.Sidecar
@impl true
def script(ctx) do
"""
#!/bin/sh
cd "#{ctx.project_root}" || exit 1
exec mix run --no-halt
"""
end
end
# config/config.exs
config :ex_tauri, :sidecars, %{custom: MyApp.Sidecar.Custom}Then select it: mix ex_tauri.dev --sidecar custom (or
ExTauri.run_dev(["dev"], sidecar: :custom)).
Summary
Callbacks
Optional build step run before the shim is written (e.g. build a release).
Returns the shell script written to context.path and made executable.
Functions
Resolves name, runs its optional prepare/1, then writes and chmods the
shim at burrito_out/desktop-<triplet>.
Maps a name to a sidecar module. Built-ins and any modules registered under
config :ex_tauri, :sidecars share one namespace; a module implementing this
behaviour may also be passed directly.
Types
@type context() :: %{ triplet: String.t(), project_root: String.t(), path: String.t(), port: integer() }
Context passed to a sidecar's callbacks.
:triplet— the Rust host target triple (e.g."aarch64-apple-darwin"):project_root— absolute path to the project root:path— absolute path the shim must be written to (Tauri's sidecar location):port— the configured dev-server port
Callbacks
Functions
Resolves name, runs its optional prepare/1, then writes and chmods the
shim at burrito_out/desktop-<triplet>.
Maps a name to a sidecar module. Built-ins and any modules registered under
config :ex_tauri, :sidecars share one namespace; a module implementing this
behaviour may also be passed directly.