GitBook: [master] 29 pages modified

This commit is contained in:
洪慈吟 2020-05-17 12:52:28 +00:00 committed by Justin Starry
parent e88629ba2a
commit 2b8298d922
2 changed files with 9 additions and 10 deletions

View File

@ -88,19 +88,19 @@ Finally, add an `index.html` file into a new folder named `static` in your app.
```bash
mkdir static
```
```
{% code title="index.html" %}
```html
```markup
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Yew Sample App</title>
<script type="module">
import init from "./wasm.js"
init()
</script>
import init from "./wasm.js"
init()
</script>
</head>
<body></body>
</html>
@ -109,8 +109,7 @@ mkdir static
## Run your App!
Using [`wasm-pack`](https://rustwasm.github.io/docs/wasm-pack/) is the preferred way to get up and running.
If you haven't already, install `wasm-pack` with `cargo install wasm-pack` and then build and start a development server by running:
Using [`wasm-pack`](https://rustwasm.github.io/docs/wasm-pack/) is the preferred way to get up and running. If you haven't already, install `wasm-pack` with `cargo install wasm-pack` and then build and start a development server by running:
```bash
wasm-pack build --target web --out-name wasm --out-dir ./static

View File

@ -12,19 +12,19 @@ First, you'll need Rust. To install Rust and the `cargo` build tool, follow the
Extra tooling is needed to facilitate the interop between WebAssembly and JavaScript. Additionally, depending on the tool you choose, they can help make deployment and packaging much less of a headache by generating all of the wrapper JavaScript code necessary to run the `.wasm` file from your app in the browser.
### [**`wasm-pack`**](https://rustwasm.github.io/docs/wasm-pack/)
### [**`wasm-pack`**](https://rustwasm.github.io/docs/wasm-pack/)
A CLI tool developed by the Rust / Wasm Working Group for packaging up WebAssembly. Best used together with the [`wasm-pack-plugin`](https://github.com/wasm-tool/wasm-pack-plugin) for Webpack.
{% page-ref page="using-wasm-pack.md" %}
### [**`wasm-bindgen`**](https://rustwasm.github.io/docs/wasm-bindgen/)
### [**`wasm-bindgen`**](https://rustwasm.github.io/docs/wasm-bindgen/)
Both a library and CLI tool and is also developed by the Rust / Wasm Working Group. It is a low level tool \(used internally by `wasm-pack`\) which facilitates JS / WebAssembly interoperability. We don't recommend using `wasm-bindgen`directly because it requires hand-writing some JavaScript to bootstrap you WebAssembly binary. However, it is possible and more info can be found on the [**`wasm-bindgen` guide**](https://rustwasm.github.io/docs/wasm-bindgen/).
{% page-ref page="using-wasm-bindgen.md" %}
### [**`cargo-web`**](https://github.com/koute/cargo-web)
### [**`cargo-web`**](https://github.com/koute/cargo-web)
The preferred web workflow tool before the introduction of `wasm-pack` and `wasm-bindgen`. It is still the **quickest** way to get up and running and worth installing to run examples that haven't been migrated to support `wasm-pack` yet.