crane/docs/examples/trunk.md

1.1 KiB

Trunk is a tool that allow you to build web apps using Rust and webassembly, including compiling scss, and distributing other assets.

Being a more specialized tool, it comes with some constraints that must be noted when using it in combination with crane:

  • Your Toolchain must have the wasm32-unknown-unknown target installed (See: Custom toolchain)
  • For craneLib.buildDepsOnly to work you will need to set the build target (See: API Reference)
  • craneLib.filterCargoSources will remove html, css, your assets folder, so you need to modify the source filtering function (See: Source filtering)
  • You will need to set wasm-bindgen-cli to a version that matches your Cargo.lock file. (See examples)

For a quick-start run the following in a fresh directory:

nix flake init -t github:ipetkov/crane#trunk

Alternatively, if you have an existing project already, copy and paste the following flake.nix:

{{#include ../../examples/trunk/flake.nix}}