refactor: change assets handling to vite-rs

chore: update dev environment

wip: handle vite tooling manually
This commit is contained in:
Alexander Navarro 2025-04-21 20:14:07 -04:00
parent 14a4d9b2b3
commit af709f2e72
26 changed files with 406 additions and 389 deletions

View file

@ -1,8 +1,27 @@
fn main() {
// we only need to bundle the templates with the
// feature is enabled.
#[cfg(feature = "bundled")]
#[cfg(feature = "vite")]
{
minijinja_embed::embed_templates!("src/templates");
let out_dir = if cfg!(feature = "embed") {
std::env::var("OUT_DIR").unwrap()
} else {
format!("../../{}", std::env::var("CPD_PUBLIC_DIR").unwrap_or(String::from("public")))
};
std::process::Command::new("bun")
.args(&["vite", "build", "--outDir", &out_dir])
.status()
.unwrap();
println!("cargo::rerun-if-changed=frontend/assets");
println!("cargo::rerun-if-changed=frontend/static");
println!("cargo::rerun-if-env-changed=CPD_PUBLIC_DIR");
println!("cargo::rerun-if-env-changed=CARGO_FEATURE_EMBED");
}
println!("cargo::rerun-if-env-changed=CARGO_FEATURE_VITE");
#[cfg(feature = "embed")]
{
minijinja_embed::embed_templates!("frontend/templates");
println!("cargo::rerun-if-changed=frontend/templates");
}
}