feat: first release

This commit is contained in:
Alexander Navarro 2025-04-11 19:13:39 -04:00
commit 154eca70dd
8 changed files with 329 additions and 0 deletions

45
README.md Normal file
View file

@ -0,0 +1,45 @@
# 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:
```rust
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",
"scripts/build.ts",
"--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
}
```