No description
| .gitignore | ||
| bun.lock | ||
| bunfig.toml | ||
| CHANGELOG.md | ||
| cog.toml | ||
| index.ts | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
tmpl-build-and-load
Wrapper around the Bun build API to compile frontend files (JS/TS, JSX/TSX, CSS, SASS, HTML) into browser native versions, with minification and code splitting enabled by default.
How to use
Cargo
Add the following to the build.rs script:
use std::io::Write;
use std::process::Command;
use std::{env, io};
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let output = Command::new("bun")
.args([
"run",
"tmpl-build-and-load",
"--outdir",
out_dir.as_str(),
"--globs",
"static/**/*.html", // change depending of where your assets are
])
.output()
.unwrap();
let _ = io::stdout().write_all(&output.stdout);
if !output.status.success() {
let _ = io::stderr().write_all(&output.stderr);
panic!("\nFailed to run command\n");
}
println!("Build completed successfully!");
println!("cargo::rerun-if-changed=build.rs");
println!("cargo::rerun-if-changed=package.json");
println!("cargo::rerun-if-changed=static"); // change depending of where your assets are
}