My approach on a very opinionated Rust WASM project builder.
This project is meant for one specific purpose: Build WASM projects fully in Rust, that are supposed to run either in the browser or with Tauri. Furthermore, it expects a specific project layout and is exceptionally limited on configuration options.
That means no mix of JS and Rust WASM, no building as a library or any of those combinations. Full blown Rust projects and nothing else.
Probably worth noting, this is my personal project for my specific setup and layouts and what not. Meaning, it's unlikely any request for new features will be accepted. If it matches your use case, great. If it doesn't, well... fork it 😛.
The following tools must be pre-installed on your system, and available through your $PATH
variable:
- Rust installed through
rustup
. - Binaryen toolset, which includes
wasm-opt
. - Dart-sass compiler.
This project relies on wasm-bindgen
as well, but the version is strictly bound to the one used in your projects. Therefore, it'll detect the right version and install it through cargo
into its own cache folder. That means it won't clash with any version that you might have already installed with cargo
or a package manager yourself.
Fellow Arch users can simply installed the needed dependencies as follows:
sudo pacman -S --needed binaryen dart-sass rustup
This project is currently not published on crates.io, and I don't feel the need to provide pre-compiled binaries. Instead, just use cargo:
cargo install --git https://github.com/dnaka91/wazzup.git
To keep configuration options to a minimum, a project must adhere to a certain file structure and at least contain the following files:
assets/main.sass
: Single source for any styling. Can alternatively bemain.scss
ormain.css
. Must only reference files from theassets/{sass,scss,css}/
folder.assets/sass/
: Additional dependencies for themain.{sass,scss,css}
file. Theassets/scss/
andassets/css/
folders can coexist next to it, if needed.assets/*
: Remaining assets, that are not stylesheets.src/
: All the Rust code.Cargo.lock
: Lock file for Rust dependencies, and mandatory to detect the usedwasm-bindgen
version.Cargo.toml
: Typical Rust project config file.index.html
: Main HTML file..gitignore
: Ignore patterns for files in the repository, that won't be watched by this project for file change detection.
A minimal project would look like this:
.
├── assets
│ └── main.sass
├── src
│ └── main.rs
├── .gitignore
├── Cargo.lock
├── Cargo.toml
└── index.html
Furthermore, the output is assembled in the dist
folder, including the WASM binary, JS glue, stylesheets, index page and any additional assets. That means, the .gitignore
should at least include:
dist/
target/
The application currently has three main commands: status
, build
and dev
.
status
searches for all needed external programs and mandatory project files, reporting there status in nice ASCII tables.build
compiles the project and all its assets into thedist/
directory.dev
spins up a local development server and rebuilds the project on file changes.
For further details, simply run the application with the -h
/--help
flag. The usage should be pretty self-explanatory from there on.
To configure Tauri to use Wazzup, adjust your tauri.conf.json
as follows:
{
"build": {
"beforeBuildCommand": "wazzup build --release",
"beforeDevCommand": "wazzup dev",
"devPath": "http://localhost:8080",
"distDir": "../dist"
// other build config ...
}
// other settings ...
}
This project is licensed under the AGPL-3.0 License (or https://www.gnu.org/licenses/agpl-3.0.html).