HomepageRs is a lightweight web project built with Rocket in Rust.
Before building and running this project, make sure the following tools are installed:
-
Rust toolchain
Install Rust via rustup.
-
Build tools
Some platforms (like Linux) require development tools and dependencies.
-
wasm-pack
Used to compile the WebAssembly module:
cargo install wasm-pack
-
cargo-watch
For automatically rebuilding and restarting the server on file changes:
cargo install cargo-watch
-
Build the WebAssembly
Navigate to the nav directory and compile it for the web:
wasm-pack build --target web --out-dir ../site/static/pkg
This outputs the compiled WebAssembly and bindings to the site/static/pkg folder, where the Rocket site can serve it.
-
Run the Rocket site
-
To manually start the backend server, navigate to the
sitedirectory and run:cargo run --release
This starts the Rocket server and serves the frontend at http://localhost:8000.
-
For automatic rebuilds during development, run the following command from the root of the project:
cargo watch -w site -s 'cd nav && wasm-pack build --target web --out-dir ../site/static/pkg && cd ../site && cargo run --release'This watches changes in the site directory, rebuilds WebAssembly, and restarts the Rocket server automatically.
-
- Be sure to re-run wasm-pack build whenever you update the nav code.
- Repository preview images have been generated with Github Social Image Generator