Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mtolmacs/vite-plugin-wasm-pack-watcher

A Vite plugin which recompiles your Rust WebAssembly project whenever you modify a Rust (*.rs) file.
https://github.com/mtolmacs/vite-plugin-wasm-pack-watcher

Last synced: 21 days ago
JSON representation

A Vite plugin which recompiles your Rust WebAssembly project whenever you modify a Rust (*.rs) file.

Awesome Lists containing this project

README

        

# vite-plugin-wasm-pack-watcher

A Vite plugin which recompiles your Rust WebAssembly project whenever you modify
a Rust (\*.rs) file.

## Usage

1. Add it to your `vite.config.(js|ts)` file and set the `build.watch` parameter
to listen for .rs file changes as well:

```ts
import { defineConfig } from "vite";
import wasmPackWatchPlugin from "vite-plugin-wasm-pack-watcher";

export default defineConfig({
build: {
watch: {
include: ["src/**/*.js", "src/**/*.ts", "src/**/*.rs"], // Watch for *.rs files
},
},
plugins: [
wasmPackWatchPlugin({
/*
buildCommand: ""
*/
}),
],
});
```

> Note: Please note that this plugin is not a replacement for [vite-plugin-wasm](https://github.com/Menci/vite-plugin-wasm)
> or similar plugins!

2. If you're importing the WASM package generated by `wasm-pack` in your package.json
you need to reference it as a "link", otherwise this plugin will keep reloading the old,
unchanged version!

```json
{
"dependencies": {
"": "link:./pkg"
}
}
```