You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clone this repo or download the zip file, extract the example folder.
example
|
|-- my-crate # rust project folder, there is a Cargo.toml in it
|-- src # front end source code
| |-- index.ts # entry point
|-- index.html # html entry
|-- vite.config.ts # vite config file
|__ package.json # npm config file
Install npm develop dependencies, in example folder run:
yarn install
# or# npm install
After that you can build rust project to WebAassembly by using wasm-pack.
wasm-pack build ./my-crate --target web
Now the my-crate module is ready, start vite dev server.
yarn dev
or
#npm run dev
Done, if below is showing.
vite v2.6.5 dev server running at:
> Local: https://localhost:3000/
ready in 169ms.
Install manually
yarn add vite vite-plugin-wasm-pack -D
# or# npm i vite vite-plugin-wasm-pack vite -D
Usage
Add this plugin to vite.config.ts
import{defineConfig}from'vite';importwasmPackfrom'vite-plugin-wasm-pack';exportdefaultdefineConfig({// pass your local crate path to the pluginplugins: [wasmPack('./my-crate')]});