-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
32 lines (27 loc) · 910 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use std::process::Command;
use std::env;
use std::path::Path;
fn main() {
println!("cargo:rerun-if-changed=src/*");
println!("cargo:rerun-if-changed=index.html");
// Create dist directory if it doesn't exist
let dist_path = Path::new("dist");
if !dist_path.exists() {
std::fs::create_dir_all(dist_path).expect("Failed to create dist directory");
}
// Copy index.html to dist
std::fs::copy("index.html", dist_path.join("index.html"))
.expect("Failed to copy index.html to dist");
// Run wasm-bindgen
let status = Command::new("wasm-bindgen")
.args(&[
"target/wasm32-unknown-unknown/release/trunk-template.wasm",
"--out-dir", "dist",
"--target", "web",
])
.status()
.expect("Failed to execute wasm-bindgen");
if !status.success() {
panic!("wasm-bindgen failed");
}
}