feat: create dev environment

This commit is contained in:
Valerio Ageno
2024-05-18 11:46:57 +02:00
parent fc1d9013f8
commit db98e0e2fd
8 changed files with 88 additions and 17 deletions
+1 -1
View File
@@ -10,6 +10,6 @@ path = "src/lib.rs"
[dependencies]
clap = { version = "4.5.4", features = ["derive"] }
cargo-watch = "8.5.2"
axum_bundler = { path = "../axum_bundler" }
tuono_bundler = { path = "../bundler"}
+14 -15
View File
@@ -1,24 +1,23 @@
use bundler::bundler;
use std::path::Path;
use std::process::{Command, Stdio};
use std::process::Command;
use std::thread;
fn spawn_vite_process() -> std::io::Result<()> {
println!("Spawing vite process");
let current_dir = std::env::current_dir()?;
pub fn run() {
let current_dir = std::env::current_dir().unwrap();
let vite_path = Path::new("node_modules/.bin/vite");
let vite = current_dir.join(vite_path);
dbg!(&vite);
let vite_handler = thread::spawn(move || {
println!("Spawing vite process");
let _ = Command::new(vite).arg("dev").output();
});
let _ = Command::new(vite)
.arg("dev")
.stdout(Stdio::inherit())
.output()?;
let build_rs_handler = thread::spawn(move || {
bundler::watch().unwrap();
});
Ok(())
}
pub fn run() {
println!("Running dev environment");
let _ = spawn_vite_process();
let _ = vite_handler.join();
let _ = build_rs_handler.join();
}