yew/website/i18n/zh-Hant/docusaurus-plugin-content-docs/version-0.18.0/getting-started/starter-templates.mdx

33 lines
1.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 初始模板
## `wasm-pack`
- [Minimal Template](https://github.com/yewstack/yew-wasm-pack-minimal) - 使用 `wasm-pack` 與 `rollup` 來建置應用程式。你必須用你自己的伺服器服務來啟動它。
- [Webpack Template](https://github.com/yewstack/yew-wasm-pack-template) - 使用 `wasm-pack` 與 [`wasm-pack-plugin`](https://github.com/wasm-tool/wasm-pack-plugin),用 Wepack 套件來簡化開發流程。
使用上述的模板與單純使用 `cargo-web` 最重要的區別在於,模板使用的是 `lib` 而不是 `bin` crate而且程式的進入點會註解 `#[wasm_bindgen]`
你的 `Cargo.toml` 必須要設定一個 `cdylib` 的 crate-type。
```text title="Cargo.toml"
[package]
name = "yew-app"
version = "0.1.0"
authors = ["Yew App Developer <name@example.com>"]
edition = "2018"
[lib]
crate-type = ["cdylib"]
[dependencies]
# for web_sys
yew = 0.15
# or for stdweb
# yew = { version = "0.15", package = "yew-stdweb" }
wasm-bindgen = "0.2"
```
## 其他的模板
- [Parcel Template](https://github.com/spielrs/yew-parcel-template) - 由一個社群成員用 [Parcel](https://parceljs.org/) 製作