Skip to content

Latest commit

 

History

History
44 lines (35 loc) · 693 Bytes

README.md

File metadata and controls

44 lines (35 loc) · 693 Bytes

vite-plugin-rust

vite-plugin-rust is a vite plugin that intergrate wasm-pack.

Getting Started

  • Config plugin in vite.config.js
const rust = require('vite-plugin-rust');

module.exports = {
  plugins: [
    rust({
      crates: {
        rust_crate: './crate',
      }
    }),
  ]
};

It's not needed to add wasm-pack generated package to package.json dependency list.

  • Wasm loading You can use wasm-pack generated package with import or dynamic import.
// Static Import
import init from 'rust_crate';
init().then(m => {
  m.greet();
});
// Dynamic Import
import('rust_crate').then(async m => {
  await m.default();
  m.greet();
});

License

MIT