New:Socket for Asana Is Now Available.Learn more
Get Started

vite-plugin-wasm-pack-watcher

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-wasm-pack-watcher

Watch for Rust file changes and rebuild the project with wasm-pack on changes.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

vite-plugin-wasm-pack-watcher

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

Usage

  • Add it to your vite.config.(js|ts) file and set the build.watch parameter to listen for .rs file changes as well:
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: "<your custom build command to run, defaults to wasm-pack build --dev>"
      */
    }),
  ],
});

Note: Please note that this plugin is not a replacement for vite-plugin-wasm or similar plugins!

  • 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!
{
  "dependencies": {
    "<your wasm package name>": "link:./pkg"
  }
}

Keywords

vite

FAQs

Package last updated on 04 Jan 2025

Related posts