@@ -1896,34 +1896,30 @@ fn main() {
18961896 // Do initial compile
18971897 if target_path.is_dir() {
18981898 let hl_files = collect_hl_files_recursive(target_path);
1899+ let out_dir = config.output.as_deref().unwrap_or("out");
1900+ let _ = fs::create_dir_all(out_dir);
18991901 let mut all_included: Vec<PathBuf> = Vec::new();
19001902 for file in &hl_files {
19011903 let path_str = file.to_string_lossy().to_string();
1902− let effective_out = config.output.as_ref().map(|o| {
1903− let rel = file.strip_prefix(target_path).unwrap_or(file);
1904− let out_p = Path::new(o).join(rel).with_extension("html");
1905− if let Some(parent) = out_p.parent() {
1906− let _ = fs::create_dir_all(parent);
1907− }
1908− out_p.to_string_lossy().to_string()
1909− });
1904+ let rel = file.strip_prefix(target_path).unwrap_or(file);
1905+ let out_p = Path::new(out_dir).join(rel).with_extension("html");
1906+ if let Some(parent) = out_p.parent() {
1907+ let _ = fs::create_dir_all(parent);
1908+ }
1909+ let effective_out = out_p.to_string_lossy().to_string();
19101910 let (_, included) = compile(
19111911 &path_str,
19121912 &CompileConfig {
19131913 dev: true,
19141914 error_overlay: true,
1915− output_path: effective_out.as_deref(),
1915+ output_path: Some(&effective_out),
19161916 ..Default::default()
19171917 },
19181918 );
19191919 all_included.extend(included);
19201920 }
19211921 let (tx, _) = tokio::sync::broadcast::channel::<()>(16);
1922− let serve_dir = config
1923− .output
1924− .as_ref()
1925− .map(PathBuf::from)
1926− .unwrap_or_else(|| target_path.to_path_buf());
1922+ let serve_dir = PathBuf::from(out_dir);
19271923 let index_path = serve_dir.join("index.html");
19281924 let server_tx = tx.clone();
19291925 let tls_for_thread = tls_config;
@@ -1953,16 +1949,24 @@ fn main() {
19531949 config.debounce_ms,
19541950 );
19551951 } else {
1952+ let out_dir = config.output.as_deref().unwrap_or("out");
1953+ let _ = fs::create_dir_all(out_dir);
1954+ let file_stem = Path::new(&target)
1955+ .file_stem()
1956+ .map(|s| s.to_os_string())
1957+ .unwrap_or_default();
1958+ let out_path = Path::new(out_dir).join(&file_stem).with_extension("html");
1959+ let out_path_str = out_path.to_string_lossy().to_string();
19561960 let (_, included) = compile(
19571961 &target,
19581962 &CompileConfig {
19591963 dev: true,
19601964 error_overlay: true,
1965+ output_path: Some(&out_path_str),
19611966 ..Default::default()
19621967 },
19631968 );
19641969 let (tx, _) = tokio::sync::broadcast::channel::<()>(16);
1965− let out_path = Path::new(&target).with_extension("html");
19661970 let server_tx = tx.clone();
19671971 let tls_for_thread = tls_config;
19681972 std::thread::spawn(move || {