@wasm-tool/wasm-pack-plugin
webpack plugin for Rust
Installation
With npm:
npm install --save-dev @wasm-tool/wasm-pack-plugin
Or with Yarn:
yarn add --dev @wasm-tool/wasm-pack-plugin
wasm-pack
We expect wasm-pack
to be in your $PATH
. See installation here.
The minimum required wasm-pack
version is 0.8.0
Linting
This project uses the prettier
with default configuration. Fo manually format the code run the lint:fix
script.
Usage
Add the loader in your webpack.config.js
:
const path = require('path')
const WasmPackPlugin = require('@wasm-tool/wasm-pack-plugin')
module.exports = {
plugins: [
new WasmPackPlugin({
crateDirectory: path.resolve(__dirname, 'crate'),
args: '--log-level warn',
extraArgs: '--no-typescript',
}),
],
}
and then import your pkg
folder from wasm-pack
:
import('./path/to/your/pkg').then((module) => {
module.run()
})