1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-05-27 20:58:41 +02:00
comprehensive-rust/src/rust-wasm-template
2023-07-26 15:21:39 +00:00
..
2023-07-26 15:21:39 +00:00
2023-07-24 22:10:51 +02:00
2023-07-21 12:05:32 +02:00

rust-wasm-template

This repository contains the minimum amount of code needed to experiment with WebAssembly. Including a web server to serve the HTML and WASM as well as the javascript boilerplate needed to load WASM.

  • /server contains the Web server as well as the static files
  • /project contains the Rust code

Installation

Note: If you are running from a devcontainer, you only need to install wasm-pack.

Rust

Recommended:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Alternatively, see the installation page.

wasm-pack

Recommended:

curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

Alternatively, see the installation page.

Run the local server

cd server

cargo run
  • On a devcontainer, go to PORTS and open the link under Local Address for Port 8080
  • Locally, visit http://localhost:8080

Build WASM and copy target to the correct path

cd project

wasm-pack build --target web && cp -r pkg ../server                                     

This command needs to be re-run to view your latest changes.