wip: handle vite tooling manually

This commit is contained in:
Alexander Navarro 2025-04-25 16:53:44 -04:00
parent 9246964edb
commit 9c1a8f030c
17 changed files with 187 additions and 333 deletions

View file

@ -1,8 +1,24 @@
use std::fs;
use std::path::Path;
fn main() {
let out_dir = std::env::var("OUT_DIR").unwrap();
// we only need to bundle the templates with the
// feature is enabled.
#[cfg(feature = "bundled")]
#[cfg(not(debug_assertions))]
{
minijinja_embed::embed_templates!("src/templates");
std::process::Command::new("bun")
.args(&["vite", "build", "--outDir", &out_dir])
.status()
.unwrap();
minijinja_embed::embed_templates!("frontend/templates");
}
#[cfg(debug_assertions)]
{
// dummy file to satisfy the compiler in dev builds
let dest_path = Path::new(&out_dir).join(".vite/manifest.json");
fs::create_dir_all(dest_path.parent().unwrap()).unwrap();
fs::write(&dest_path, "{}").unwrap();
}
}