diff --git a/crates/tuono/src/cli.rs b/crates/tuono/src/cli.rs index f00b3bd1..6703f09c 100644 --- a/crates/tuono/src/cli.rs +++ b/crates/tuono/src/cli.rs @@ -23,6 +23,10 @@ enum Actions { #[arg(short, long = "static")] /// Statically generate the website HTML ssg: bool, + + #[arg(short, long)] + /// Prevent to export the js assets + no_js_emit: bool, }, /// Scaffold a new project New { @@ -42,12 +46,12 @@ struct Args { action: Actions, } -fn init_tuono_folder(mode: Mode) -> std::io::Result<()> { +fn init_tuono_folder(mode: Mode) -> std::io::Result { check_tuono_folder()?; - bundle_axum_source(mode)?; + let app = bundle_axum_source(mode)?; create_client_entry_files()?; - Ok(()) + Ok(app) } fn check_ports(mode: Mode) { @@ -83,13 +87,17 @@ pub fn app() -> std::io::Result<()> { Actions::Dev => { check_ports(Mode::Dev); - init_tuono_folder(Mode::Dev)?; + let _ = init_tuono_folder(Mode::Dev)?; watch::watch().unwrap(); } - Actions::Build { ssg } => { - init_tuono_folder(Mode::Prod)?; - let app = App::new(); + Actions::Build { ssg, no_js_emit } => { + let app = init_tuono_folder(Mode::Prod)?; + + if no_js_emit { + println!("Rust build successfully finished"); + return Ok(()); + } if ssg && app.has_dynamic_routes() { // TODO: allow dynamic routes static generation diff --git a/crates/tuono/src/source_builder.rs b/crates/tuono/src/source_builder.rs index 88a64233..0fc67a1f 100644 --- a/crates/tuono/src/source_builder.rs +++ b/crates/tuono/src/source_builder.rs @@ -123,7 +123,7 @@ fn create_modules_declaration(routes: &HashMap) -> String { route_declarations } -pub fn bundle_axum_source(mode: Mode) -> io::Result<()> { +pub fn bundle_axum_source(mode: Mode) -> io::Result { let base_path = std::env::current_dir().unwrap(); let app = App::new(); @@ -132,7 +132,7 @@ pub fn bundle_axum_source(mode: Mode) -> io::Result<()> { create_main_file(&base_path, &bundled_file); - Ok(()) + Ok(app) } fn generate_axum_source(app: &App, mode: Mode) -> String {