2.0.11 • Published 2 years ago

vite-plugin-rsw v2.0.11

Weekly downloads
54
License
MIT
Repository
github
Last release
2 years ago

vite-plugin-rsw

wasm-pack plugin for Vite

npm npm downloads vite version chat

awesome-rsw Rust WebAssembly

rsw versionvite version
>= 2.0.0>= 2.8.0
>= 1.8.0>= 2.4.0
1.7.02.0.0 ~ 2.3.8

Features

  • HMR
  • Friendly error message - browser and terminal

Pre-installed

  • rust
  • nodejs
  • wasm-pack
  • rsw-rs: rsw = rs(rust) → w(wasm) - A command-line tool for automatically rebuilding local changes, based on the wasm-pack implementation.

Usage

Step 1

Install rsw

cargo install rsw

Install vite-plugin-rsw

# With NPM:
npm i -D vite-plugin-rsw

# With Yarn:
yarn add -D vite-plugin-rsw

Step 2

Edit vite.config.ts

import { defineConfig } from 'vite';
import { ViteRsw } from 'vite-plugin-rsw';

export default defineConfig({
  plugins: [
    ViteRsw(),
  ],
})

Step 3

Edit package.json

"scripts": {
+   "dev": "rsw watch & vite",
+   "build": "rsw build && tsc && vite build",
+   "rsw": "rsw"
}

Step 4

rsw.toml options

  1. Initial rsw.toml

    # yarn rsw -h
    yarn rsw init
  2. Generate rust crate

    # rsw.toml
    [new]
    # using: wasm-pack | rsw | user, default is `wasm-pack`
    using = "wasm-pack"
    yarn rsw new rsw-hello
  3. Edit rsw.toml

    # link type: npm | yarn | pnpm, default is `npm`
    cli = "npm"
    
    [[crates]]
    name = "rsw-hello"
    # <npm|yarn|pnpm> link
    # ⚠️ Note: must be set to `true`, default is `false`
    link = true

Step 5

Start dev server

# rsw watch & vite
yarn dev

Step 6

Deploy

yarn build

Example

  • WA+ - 🤩 Making a web page more like a desktop application is just the beginning, the possibilities are unlimited, up to your imagination!
  • Demo - 🎲 Learning WebAssembly
  • Oh My Box - 🔮 Development toolbox, and more...

Related

create-mpl - ⚡️ Create a project in seconds!

# Quickly initialize a wasm project

# npm 6.x
npm init mpl@latest my-app --type wasm

# npm 7+, extra double-dash is needed:
npm init mpl@latest my-app -- --type wasm

微信

群二维码已过期,关注公众号《浮之静》,发送“进群”,我将拉你进群一起学习。

License

MIT License © 2021 lencx

2.0.11

2 years ago

2.0.10

2 years ago

2.0.9

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.8

2 years ago

2.0.3

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.10.2

2 years ago

1.10.1

2 years ago

1.10.0

3 years ago

1.9.3

3 years ago

1.9.2

3 years ago

1.9.1

3 years ago

1.9.0

3 years ago

1.8.1

3 years ago

1.8.0

3 years ago

1.7.0

3 years ago

1.6.5

3 years ago

1.6.4

3 years ago

1.6.3

3 years ago

1.6.2

3 years ago

1.6.1

3 years ago

1.4.3

3 years ago

1.6.0

3 years ago

1.4.2

3 years ago

1.5.0

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.0

3 years ago

1.2.1

3 years ago

1.1.11

3 years ago

1.1.10

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.7

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago