Replace 'wasm-pack' by 'trunk'
This commit is contained in:
parent
ec582ad68f
commit
08c4238dcb
14 changed files with 42 additions and 85 deletions
|
|
@ -56,8 +56,3 @@ gloo = "0.11"
|
|||
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
||||
# code size when deploying.
|
||||
console_error_panic_hook = { version = "0.1", optional = true }
|
||||
|
||||
# wasm-opt is used by default: https://docs.rs/wasm-opt/latest/wasm_opt/
|
||||
# Uncomment the following lines to disable it.
|
||||
# [package.metadata.wasm-pack.profile.release]
|
||||
# wasm-opt = false
|
||||
|
|
|
|||
12
frontend/Trunk.toml
Normal file
12
frontend/Trunk.toml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[build]
|
||||
dist = "../backend/static/wasm"
|
||||
public_url = "/static"
|
||||
filehash = false
|
||||
minify = "on_release"
|
||||
|
||||
# Here we don't want the file 'index.html' in the final directory.
|
||||
# Is there a way to not generate it at first?
|
||||
[[hooks]]
|
||||
stage = "post_build"
|
||||
command = "rm"
|
||||
command_arguments = ["../backend/static/wasm/.stage/index.html"]
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
def main [release: bool = false] {
|
||||
|
||||
mut wasm_pack_args = [ build --target web --no-pack --no-typescript ]
|
||||
if $release {
|
||||
$wasm_pack_args ++= [ --release ]
|
||||
} else {
|
||||
$wasm_pack_args ++= [ --dev ]
|
||||
}
|
||||
|
||||
wasm-pack ...$wasm_pack_args
|
||||
|
||||
cp pkg/frontend.js ../backend/static
|
||||
cp pkg/frontend_bg.wasm ../backend/static
|
||||
}
|
||||
7
frontend/index.html
Normal file
7
frontend/index.html
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<link data-trunk rel="rust" data-wasm-opt="z" />
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
// Note that a dynamic `import` statement here is required due to
|
||||
// webpack/webpack#6615, but in theory `import { greet } from './pkg';`
|
||||
// will work here one day as well!
|
||||
const rust = import('./pkg');
|
||||
|
||||
rust
|
||||
.then(m => m.greet('Paul!'))
|
||||
.catch(console.error);
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"scripts": {
|
||||
"build": "rspack build",
|
||||
"serve": "rspack serve"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rspack/cli": "^1.0.14",
|
||||
"@rspack/core": "^1.0.14",
|
||||
"@wasm-tool/wasm-pack-plugin": "1.5.0",
|
||||
"html-webpack-plugin": "^5.6.0"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
const path = require('path');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const webpack = require('webpack');
|
||||
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
|
||||
|
||||
module.exports = {
|
||||
entry: './index.js',
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
filename: 'index.js',
|
||||
},
|
||||
plugins: [
|
||||
new HtmlWebpackPlugin(),
|
||||
new WasmPackPlugin({
|
||||
crateDirectory: path.resolve(__dirname, ".")
|
||||
}),
|
||||
],
|
||||
mode: 'development',
|
||||
experiments: {
|
||||
asyncWebAssembly: true
|
||||
}
|
||||
};
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
# See 'package.json'.
|
||||
npm run serve
|
||||
Loading…
Add table
Add a link
Reference in a new issue