A collection of scripts to facilitate using Cargo with Trunk to build and serve Rust projects for local testing.
This repository contains shell scripts for macOS/Linux and PowerShell scripts for Windows that automate the process of cloning a Rust project from a private repository, building it using Cargo, compiling with Trunk, and copying the resulting build's unique identifier to the clipboard for easy access.
- Rust and Cargo must be installed on your system. You can install them from here.
- Trunk must be installed. Instructions can be found here.
- For macOS/Linux:
xclip
is required for clipboard functionality. - For Windows: PowerShell is used to run the script.
# sh or PowerShell
cargo build --target=wasm32-unknown-unknown
# sh
cargo build && trunk serve
# PowerShell
cargo build
if ($?) {
trunk serve
}
# sh
cargo build --release && trunk serve --release
# PowerShell
cargo build --release
if ($?) {
trunk serve --release
}
- Clone the repository to your local machine:
git clone https://github.com/heyfoz/rust-cargo-build-trunk-serve.git