generated from alecodes/base-template
wip: handle vite tooling manually
This commit is contained in:
parent
9246964edb
commit
9c1a8f030c
17 changed files with 187 additions and 333 deletions
20
build.rs
20
build.rs
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue