mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
* tree-wide: update links to https://rustwasm.github.io/wasm-bindgen https://rustwasm.github.io/wasm-bindgen -> https://wasm-bindgen.github.io/wasm-bindgen https://rustwasm.github.io/docs/wasm-pack -> https://drager.github.io/wasm-pack/book/ https://rustwasm.github.io/wasm-pack -> https://github.com/drager/wasm-pack
161 lines
5.9 KiB
Plaintext
161 lines
5.9 KiB
Plaintext
---
|
|
description: Set yourself up for success
|
|
---
|
|
|
|
# 專案設定
|
|
|
|
## Rust
|
|
|
|
首先,你的電腦裡必須要安裝 Rust。請參考[官網的教學](https://www.rust-lang.org/tools/install)安裝 Rust 與 `cargo` 這個套件管理工具。
|
|
|
|
## **Wasm 編譯工具**
|
|
|
|
我們需要額外的工具來增加 WebAssembly 與 JavaScript 的互操作性。此外,根據你選擇的工具,他們可以產生當你的應用程式運行在瀏覽器時, `.wasm` 檔案所需要的 JavaScript 程式碼,減少佈署與打包的麻煩。
|
|
|
|
### [**`wasm-pack`**](https://drager.github.io/wasm-pack/book/)
|
|
|
|
一套 CLI 工具,由 Rust/Wasm Working Group 為了編譯並打包 WebAssembly 所開發的。最好與 Webpack 的 [`wasm-pack-plugin`](https://github.com/wasm-tool/wasm-pack-plugin) 搭配使用。
|
|
|
|
[開始使用 wasm-pack](project-setup/using-wasm-pack.mdx)
|
|
|
|
### [**`cargo-web`**](https://github.com/koute/cargo-web)
|
|
|
|
在 `wasm-pack` 與 `wasm-bindgen` 出來之前,這是我們的首選工具。在安裝與執行方面,他的速度仍是最快的,我們推薦你安裝他去執行我們的那些還沒有使用 `wasm-pack` 的範例。
|
|
|
|
[開始使用 cargo-web](project-setup/using-cargo-web.mdx)
|
|
|
|
### 比較
|
|
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th style={{ textAlign: 'left' }}></th>
|
|
<th style={{ textAlign: 'left' }}>
|
|
<code>wasm-pack</code>
|
|
</th>
|
|
<th style={{ textAlign: 'left' }}>
|
|
<code>cargo-web</code>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td style={{ textAlign: 'left' }}>
|
|
專案狀態
|
|
</td>
|
|
<td style={{ textAlign: 'left' }}>
|
|
持續由{' '}
|
|
<a href="https://rustwasm.github.io/">
|
|
Rust / Wasm Working Group
|
|
</a>{' '}
|
|
維護中
|
|
</td>
|
|
<td style={{ textAlign: 'left' }}>
|
|
GitHub Repo
|
|
已經六個月以上沒有動靜了
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td style={{ textAlign: 'left' }}>
|
|
開發體驗
|
|
</td>
|
|
<td style={{ textAlign: 'left' }}>
|
|
還可以,需要搭配
|
|
Webpack
|
|
</td>
|
|
<td style={{ textAlign: 'left' }}>
|
|
可以動!另外無需外部套件支援
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td style={{ textAlign: 'left' }}>
|
|
本地端的伺服器 (Local
|
|
Server)
|
|
</td>
|
|
<td style={{ textAlign: 'left' }}>
|
|
搭配 <code>webpack</code> 插件
|
|
</td>
|
|
<td style={{ textAlign: 'left' }}>支援</td>
|
|
</tr>
|
|
<tr>
|
|
<td style={{ textAlign: 'left' }}>
|
|
當檔案被更動,自動重編譯
|
|
</td>
|
|
<td style={{ textAlign: 'left' }}>
|
|
搭配 <code>webpack</code> 插件
|
|
</td>
|
|
<td style={{ textAlign: 'left' }}>支援</td>
|
|
</tr>
|
|
<tr>
|
|
<td style={{ textAlign: 'left' }}>
|
|
無頭瀏覽器測試
|
|
</td>
|
|
<td style={{ textAlign: 'left' }}>
|
|
<a href="https://drager.github.io/wasm-pack/book/commands/test.html">
|
|
Supported
|
|
</a>
|
|
</td>
|
|
<td style={{ textAlign: 'left' }}>
|
|
<a href="https://github.com/koute/cargo-web#features">
|
|
Supported
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td style={{ textAlign: 'left' }}>
|
|
支援的目標程式碼
|
|
</td>
|
|
<td style={{ textAlign: 'left' }}>
|
|
<ul>
|
|
<li>
|
|
<code>wasm32-unknown-unknown</code>
|
|
</li>
|
|
</ul>
|
|
</td>
|
|
<td style={{ textAlign: 'left' }}>
|
|
<ul>
|
|
<li>
|
|
<code>wasm32-unknown-unknown</code>
|
|
</li>
|
|
<li>
|
|
<code>wasm32-unknown-emscripten</code>
|
|
</li>
|
|
<li>
|
|
<code>asmjs-unknown-emscripten</code>
|
|
</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td style={{ textAlign: 'left' }}>
|
|
<code>web-sys</code>
|
|
</td>
|
|
<td style={{ textAlign: 'left' }}>相容</td>
|
|
<td style={{ textAlign: 'left' }}>不相容</td>
|
|
</tr>
|
|
<tr>
|
|
<td style={{ textAlign: 'left' }}>
|
|
<code>stdweb</code>
|
|
</td>
|
|
<td style={{ textAlign: 'left' }}>相容</td>
|
|
<td style={{ textAlign: 'left' }}>相容</td>
|
|
</tr>
|
|
<tr>
|
|
<td style={{ textAlign: 'left' }}>
|
|
範例用法
|
|
</td>
|
|
<td style={{ textAlign: 'left' }}>
|
|
<a href="https://github.com/yewstack/yew-wasm-pack-minimal">
|
|
新手模板
|
|
</a>
|
|
</td>
|
|
<td style={{ textAlign: 'left' }}>
|
|
Yew 範例的
|
|
<a href="https://github.com/yewstack/yew/blob/master/examples/build_all.sh">
|
|
編譯腳本
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|