# `mix plushie.build`
[🔗](https://github.com/plushie-ui/plushie-elixir/blob/v0.7.2/lib/mix/tasks/plushie.build.ex#L1)

Build the plushie renderer binary and/or WASM renderer from source.

Delegates the heavy lifting to the `cargo-plushie` Cargo subcommand:
this task discovers the project's native widgets, writes a small
"renderer spec" Cargo.toml into `_build/<env>/plushie-renderer-spec/`,
and then shells out to `cargo plushie build` against that manifest.
cargo-plushie handles widget collision checks, workspace generation,
and the final cargo invocation.

When a local source checkout is available (`PLUSHIE_RUST_SOURCE_PATH`),
the spec is built against local path dependencies; otherwise cargo-plushie
resolves plushie crates from crates.io using `PLUSHIE_RUST_VERSION`.

## Prerequisites

- **Rust toolchain** 1.92+ (install via https://rustup.rs)
- **cargo-plushie** on PATH, or `PLUSHIE_RUST_SOURCE_PATH` pointing at a
  local plushie-rust checkout for development.
- **wasm-pack** (for `--wasm` only): install via https://rustwasm.github.io/wasm-pack/

## Usage

    mix plushie.build              # build native binary (default)
    mix plushie.build --release    # optimized release build
    mix plushie.build --wasm       # build WASM renderer only
    mix plushie.build --bin --wasm # build both
    mix plushie.build --verbose    # print cargo output on success

## Options

- `--bin`: Build the native binary
- `--wasm`: Build the WASM renderer via wasm-pack
- `--bin-file PATH`: Override native binary destination
- `--wasm-dir PATH`: Override WASM output directory
- `--release`: Build with optimizations (also implied by `MIX_ENV=prod`)
- `--verbose`: Print full cargo output on successful builds
- `--update`: Force a clean rebuild by wiping the spec scratch directory

## Config

Artifact selection and output paths can be set in `config.exs`:

    config :plushie,
      artifacts: [:bin, :wasm],       # which artifacts to build
      bin_file: "priv/bin/plushie-renderer",  # binary destination
      wasm_dir: "priv/static"         # WASM output directory

CLI flags override config. Default artifacts: `[:bin]`.

## Native widgets

Native widgets are auto-detected via the `Plushie.Widget` protocol.
Any module implementing the protocol and exporting `native_crate/0`
is listed as a path dependency in the generated spec. cargo-plushie
reads `[package.metadata.plushie.widget]` from each widget's own
`Cargo.toml` to derive the type name and constructor expression.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
