Skip to content

Latest commit

 

History

History
 
 

#17-webpack-v3-rust

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

This example shows you how to use Rust in the Web with webpack v3 (current stable).

Install

  • Install rust.

  • Install WebAssembly target

rustup update
rustup component add wasm32-unknown-unknown --toolchain nightly
  • Install wasm-gc (works better than wasm-opt from binaryen)
cargo install --git https://github.com/alexcrichton/wasm-gc
  • Install node modules
npm i
  • Install web server
npm i -g webpack-dev-server

Build

  • Build rust source
rustc +nightly --target wasm32-unknown-unknown -O imul.rs --crate-type=cdylib
wasm-gc imul.wasm imul.wasm
  • Finalise using webpack
webpack

Run

  • Start web server
webpack-dev-server
  • Open dev tools / console
$ 2 * 3 = 6