IMI-eRnD-Be / wasm-run

Bundles and tooling for Rust WASM frontend application
MIT License
35 stars 3 forks source link

This repository is now deprecated in favor of xtask-wasm. Only patch fixes will be accepted.

wasm-run

Rust Latest Version Docs.rs LOC Dependency Status License

Synopsis

Build tool that replaces cargo run to build WASM projects. Just like webpack, wasm-run offers a great deal of customization.

To build your WASM project you normally need an external tool like wasm-bindgen, wasm-pack or cargo-wasm. wasm-run takes a different approach: it's a library that you install as a dependency to your project. Because of that you don't need any external tool, the tooling is built as part of your dependencies, which makes the CI easier to set up and reduce the hassle for new comers to start working on the project.

To build your project for production you can use the command cargo run -- build. You can also run a development server that rebuilds automatically when the code changes: cargo run -- serve. It doesn't rebuild everything, only the backend if the backend changed or the frontend if the frontend changed.

Please note that there is a space between -- and build and between -- and serve!

One of the main advantage of this library is that it provides greater customization: you can set a few hooks during the build process in order to customize the build directory or use a template to generate your index.html, download some CSS, ... you name it. I personally use it to reduce the amount of files by bundling the CSS and the JS into the index.html so I had only two files (index.html, app_bg.wasm).

Examples

There are 3 basic examples to help you get started quickly:

Usage

All the details about the hooks can be found on the macro [main].

Additional Information

Features

License: MIT OR Apache-2.0