# vite-plugin-wasm-rust

> A lightweight wrapper for wasm-pack, designed to enhance the experience of building websites in rust.

Latest version **1.0.2** (published 2024-09-03) · (MIT OR Apache-2.0) license · 0 weekly downloads

## Install

```sh
npm install vite-plugin-wasm-rust
pnpm add vite-plugin-wasm-rust
yarn add vite-plugin-wasm-rust
bun add vite-plugin-wasm-rust
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2024-09-03 |
| First published | 2024-09-03 |
| Weekly downloads | 0 |
| License | (MIT OR Apache-2.0) |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10.16.0 |
| Dependencies | 0 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | alfatm |
| Maintainers | alfatm |
| Keywords | plugin, Rust, vite, wasm-pack, wasm, WebAssembly |

## Links

- npm: https://www.npmjs.com/package/vite-plugin-wasm-rust
- Repository: https://github.com/alfatm/vite-plugin-wasm-rust
- Homepage: https://github.com/alfatm/vite-plugin-wasm-rust/tree/master/#readme
- Issues: https://github.com/alfatm/vite-plugin-wasm-rust/issues
- npm.io page: https://npm.io/package/vite-plugin-wasm-rust

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2024-09-03
- 1.0.1 — 2024-09-03
- 1.0.0 — 2024-09-03

## README

# vite-plugin-wasm-rust

A lightweight wrapper for wasm-pack, designed to enhance the experience of building websites in rust.

## Features

- Supports Cargo workspaces
- Monitors files and directories for changes
- Rebuilds and reloads browser page upon file modifications
- Displays compilation errors directly in the browser
- Small, easy to read and modify

## Getting Started

Add vite.config.js to build and watch rust files in `src` dir

```js
import { defineConfig } from "vite";
import viteWasmPack from "vite-plugin-wasm-rust";

export default defineConfig(({ mode }) => {
  const release = mode != "development";
  return {
    root: ".",
    build: {
      target: "esnext",
    },
    server: {
      hmr: { overlay: true },
    },
    plugins: [
      viteWasmPack({
        build: {
          crate: "./",
          release: release,
          enable_opt: release,
        },
        watch: {
          include: ["./src/", "./styles"],
          exclude: ["./dist/**"],
        },
      }),
    ],
  };
});
```

add scripts to package.json

```json
{
  "scripts": {
    "dev": "vite -c vite.config.js",
    "build": "vite build -c vite.config.js"
  }
}
```

then run dev mode

```sh
npm run dev
```

## License

MIT or Apache 2.0

---
_Source: https://npm.io/package/vite-plugin-wasm-rust · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
