This example is designed for creating Web applications with Webpack, Rust-generated WebAssembly, TypeScript and Less with minified class selectors.
Based on rust-webpack-example. Differences:
- Wasm and WebPack files are contained in different folders to avoid conflicts in file names.
- JavaScript compiled from TypeScript.
- CSS compiled from LESS and compressed with clean-css
- CSS selectors are minified/uglified with rename-css-selectors.
Run bash setup.sh
to install rust and npm,
build wasm package for npm and initialize npm package.
- Install rust and npm.
- Run
cd wasm && wasm-pack build --out-name index
- Run
cd www && npm install
cd www && npm run build
to build application in production mode towww/dist
.cd www && npm run host
to locally host application fromwww/dist
with Simple-http-server.cd www && npm run debug
to run webpack-dev-server with application in development mode.cd www && npm run test
to run application node and browser tests.
-
npm install
failed withCould not install from "../wasm/pkg" as it does not contain a package.json file
.This happened because
wasm-pack build
failed or had not beed called beforenpm install
was called. -
Error importing `index.ts`: TypeError: "Response has unsupported MIME type"
in browser console when hosting/www/dist/
.Some http servers incorrectly recognize wasm file MIME types. Simple-http-server does it right.
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.