这是在网页中使用编译好的 wasm 模块的一个示例。本仓库是 这个仓库 的子模块,克隆它就能连带本仓库一起克隆到本地。
要调试或打包,你需要先安装 npm 。
- 找到 www/package.json
- 删除包含
"wasm-fa": "file:../pkg"
的那一行代码。 - 运行
npm install
- 将删除的代码复原。
- 运行
npm install
我也不知道为什么需要这么做,可能是npm不能同时导入本地依赖和远程依赖吧。如果你直接npm install不会报错的话那也可以直接npm install。
运行 npm run start
即可从 http://localhost:8080/ 看到网页。
运行 npm run build
会在 www/disc 目录生成打包好的网页项目文件,将这些文件复制到你的web服务器的相应目录下即可部署。
Some readme contents of the original project below.
.gitignore
: ignoresnode_modules
LICENSE-APACHE
andLICENSE-MIT
: most Rust projects are licensed this way, so these are included for youREADME.md
: the file you are reading now!index.html
: a bare bones html document that includes the webpack bundleindex.js
: example js file with a comment showing how to import and use a wasm pkgpackage.json
andpackage-lock.json
:- pulls in devDependencies for using webpack:
- defines a
start
script to runwebpack-dev-server
webpack.config.js
: configuration file for bundling your js with webpack
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.