@@ -1896,34 +1896,30 @@ fn main() {
1896 // Do initial compile
1896 // Do initial compile
1897 if target_path.is_dir() {
1897 if target_path.is_dir() {
1898 let hl_files = collect_hl_files_recursive(target_path);
1898 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);
1899 let mut all_included: Vec<PathBuf> = Vec::new();
1901 let mut all_included: Vec<PathBuf> = Vec::new();
1900 for file in &hl_files {
1902 for file in &hl_files {
1901 let path_str = file.to_string_lossy().to_string();
1903 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 rel = file.strip_prefix(target_path).unwrap_or(file);
1904− let out_p = Path::new(o).join(rel).with_extension("html");
1905+ let out_p = Path::new(out_dir).join(rel).with_extension("html");
1905− if let Some(parent) = out_p.parent() {
1906+ if let Some(parent) = out_p.parent() {
1906− let _ = fs::create_dir_all(parent);
1907+ let _ = fs::create_dir_all(parent);
1908− out_p.to_string_lossy().to_string()
1909+ let effective_out = out_p.to_string_lossy().to_string();
1910 let (_, included) = compile(
1910 let (_, included) = compile(
1911 &path_str,
1911 &path_str,
1912 &CompileConfig {
1912 &CompileConfig {
1913 dev: true,
1913 dev: true,
1914 error_overlay: true,
1914 error_overlay: true,
1915− output_path: effective_out.as_deref(),
1915+ output_path: Some(&effective_out),
1916 ..Default::default()
1916 ..Default::default()
1919 all_included.extend(included);
1919 all_included.extend(included);
1921 let (tx, _) = tokio::sync::broadcast::channel::<()>(16);
1921 let (tx, _) = tokio::sync::broadcast::channel::<()>(16);
1922− let serve_dir = config
1922+ let serve_dir = PathBuf::from(out_dir);
1925− .map(PathBuf::from)
1926− .unwrap_or_else(|| target_path.to_path_buf());
1927 let index_path = serve_dir.join("index.html");
1923 let index_path = serve_dir.join("index.html");
1928 let server_tx = tx.clone();
1924 let server_tx = tx.clone();
1929 let tls_for_thread = tls_config;
1925 let tls_for_thread = tls_config;
@@ -1953,16 +1949,24 @@ fn main() {
1953 config.debounce_ms,
1949 config.debounce_ms,
1955 } else {
1951 } 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)
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();
1956 let (_, included) = compile(
1960 let (_, included) = compile(
1957 &target,
1961 &target,
1958 &CompileConfig {
1962 &CompileConfig {
1959 dev: true,
1963 dev: true,
1960 error_overlay: true,
1964 error_overlay: true,
1965+ output_path: Some(&out_path_str),
1961 ..Default::default()
1966 ..Default::default()
1964 let (tx, _) = tokio::sync::broadcast::channel::<()>(16);
1969 let (tx, _) = tokio::sync::broadcast::channel::<()>(16);
1965− let out_path = Path::new(&target).with_extension("html");
1966 let server_tx = tx.clone();
1970 let server_tx = tx.clone();
1967 let tls_for_thread = tls_config;
1971 let tls_for_thread = tls_config;
1968 std::thread::spawn(move || {
1972 std::thread::spawn(move || {