Watch migration and template dirs
This commit is contained in:
parent
79667c15b8
commit
a96af0d6ea
1 changed files with 7 additions and 1 deletions
8
build.rs
8
build.rs
|
|
@ -6,7 +6,10 @@ use std::{
|
||||||
|
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
|
const MIGRATION_DIR: &str = "migrations";
|
||||||
const STATIC_DIR: &str = "static";
|
const STATIC_DIR: &str = "static";
|
||||||
|
const TEMPLATE_DIR: &str = "templates";
|
||||||
|
|
||||||
const STATIC_OUT_DIR: &str = "target/static";
|
const STATIC_OUT_DIR: &str = "target/static";
|
||||||
const STATIC_IGNORE_EXT: &[&str] = &["ts"];
|
const STATIC_IGNORE_EXT: &[&str] = &["ts"];
|
||||||
|
|
||||||
|
|
@ -42,13 +45,16 @@ fn copy_static_files() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
watch_dir(MIGRATION_DIR.as_ref());
|
||||||
|
watch_dir(STATIC_DIR.as_ref());
|
||||||
|
watch_dir(TEMPLATE_DIR.as_ref());
|
||||||
|
|
||||||
// Since remove_dir_all fails if the directory doesn't exist, we ensure it
|
// Since remove_dir_all fails if the directory doesn't exist, we ensure it
|
||||||
// exists before deleting it. This way, we can use the remove_dir_all Result
|
// exists before deleting it. This way, we can use the remove_dir_all Result
|
||||||
// to ensure the directory was deleted successfully.
|
// to ensure the directory was deleted successfully.
|
||||||
fs::create_dir_all(STATIC_OUT_DIR).unwrap();
|
fs::create_dir_all(STATIC_OUT_DIR).unwrap();
|
||||||
fs::remove_dir_all(STATIC_OUT_DIR).unwrap();
|
fs::remove_dir_all(STATIC_OUT_DIR).unwrap();
|
||||||
|
|
||||||
watch_dir(STATIC_DIR.as_ref());
|
|
||||||
run_tsc();
|
run_tsc();
|
||||||
copy_static_files();
|
copy_static_files();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue