generated from alecodes/base-template
refactor: change assets handling to vite-rs
chore: update dev environment wip: handle vite tooling manually
This commit is contained in:
parent
14a4d9b2b3
commit
af709f2e72
26 changed files with 406 additions and 389 deletions
27
build.rs
27
build.rs
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue