generated from alecodes/base-template
build: simplify build & run process of FE files
use external bun packages to bundle files, run this package in the build.rs script
This commit is contained in:
parent
e379967907
commit
6ee345763f
6 changed files with 40 additions and 77 deletions
36
build.rs
36
build.rs
|
|
@ -1,5 +1,33 @@
|
|||
fn main() {
|
||||
// only enable in production build
|
||||
#[cfg(not(debug_assertions))]
|
||||
minijinja_embed::embed_templates!("dist");
|
||||
use std::io::Write;
|
||||
use std::process::Command;
|
||||
use std::{env, io};
|
||||
|
||||
fn cmd(cmd: &mut Command) {
|
||||
let output = cmd.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");
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
|
||||
cmd(Command::new("bun").args(["install"]));
|
||||
cmd(Command::new("bun").args([
|
||||
"run",
|
||||
"tmpl-build-and-load",
|
||||
"--outdir",
|
||||
out_dir.as_str(),
|
||||
"--globs",
|
||||
"frontend/templates/**/*.html",
|
||||
]));
|
||||
|
||||
println!("Build completed successfully!");
|
||||
|
||||
println!("cargo::rerun-if-changed=build.rs");
|
||||
println!("cargo::rerun-if-changed=package.json");
|
||||
println!("cargo::rerun-if-changed=frontend");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue