In order to use this loader you need to install it by cloning this repository:
npm i --save cargo-web-loader
and then add it to your webpack config accordingly:
// Cargo web crate loader
{
test: /Cargo.toml$/,
loaders: [
{
loader: "cargo-web-loader",
options: {
flags: '',
bin: false,
release: true,
verbose: false,
features: ""
}
}],
},
// WebAssembly loader. For testing purposes
{
test: /\.wasm$/,
loader: require.resolve('file-loader'),
options: {
name: 'static/wasm/[name].[hash:8].[ext]'
}
},
Finally you can import/require any Cargo.toml file and use it as documented in the cargo-web project.
Credit goes to dflemstr and his rust-native-wasm-loader which provided the groundwork for this loader.