mix raxol.wasm (Raxol v2.0.1)
View SourceCompiles Raxol to WebAssembly for web deployment.
Usage
mix raxol.wasm [options]Options
--watch- Watch for changes and rebuild automatically--optimize- Enable WASM optimization (default: true)--release- Build in release mode with maximum optimization--clean- Clean build artifacts before building--serve- Start a web server to test the WASM build
Examples
# Build WASM module
mix raxol.wasm
# Build with watch mode for development
mix raxol.wasm --watch
# Build optimized release version
mix raxol.wasm --release
# Clean and rebuild
mix raxol.wasm --clean
# Build and serve for testing
mix raxol.wasm --serveConfiguration
Configure WASM build in config/wasm.exs:
config :raxol, :wasm,
output_dir: "priv/static/wasm",
optimization_level: 2,
initial_memory: 16,
maximum_memory: 256Requirements
Requires Rust toolchain with wasm32-unknown-unknown target:
rustup target add wasm32-unknown-unknownOptional: wasm-opt for optimization:
npm install -g wasm-optOutput
Generates the following files:
priv/static/wasm/raxol.wasm- WebAssembly modulepriv/static/js/raxol-terminal.js- JavaScript bindingspriv/static/wasm/index.html- Demo HTML page
Deployment
Copy the generated files to your web server:
cp -r priv/static/wasm/* /var/www/html/
cp -r priv/static/js/* /var/www/html/js/Or use with a bundler like Webpack or Vite:
import { RaxolTerminal } from './raxol-terminal.js';
const terminal = new RaxolTerminal(80, 24);
await terminal.initialize('/wasm/raxol.wasm');