diff --git a/src/compile/tailwind.rs b/src/compile/tailwind.rs index a40a8ae5..0001cd1b 100644 --- a/src/compile/tailwind.rs +++ b/src/compile/tailwind.rs @@ -34,7 +34,13 @@ pub async fn compile_tailwind( if done { log::info!("Tailwind finished {}", GRAY.paint(line)); - Ok(Outcome::Success(output.stdout())) + match fs::read_to_string(&tw_conf.tmp_file).await { + Ok(content) => Ok(Outcome::Success(content)), + Err(e) => { + log::error!("Failed to read tailwind result: {e}"); + Ok(Outcome::Failed) + } + } } else { log::warn!("Tailwind failed {}", GRAY.paint(line)); println!("{}\n{}", output.stdout(), output.stderr()); @@ -77,6 +83,8 @@ pub async fn tailwind_process(cmd: &str, tw_conf: &TailwindConfig) -> Result<(St tw_conf.input_file.as_str(), "--config", tw_conf.config_file.as_str(), + "--output", + tw_conf.tmp_file.as_str(), ]; let line = format!("{} {}", cmd, args.join(" ")); let mut command = Command::new(tailwind); diff --git a/src/config/project.rs b/src/config/project.rs index 25ff3927..0de753b9 100644 --- a/src/config/project.rs +++ b/src/config/project.rs @@ -185,6 +185,8 @@ pub struct ProjectConfig { #[serde(skip)] pub config_dir: Utf8PathBuf, + #[serde(skip)] + pub tmp_dir: Utf8PathBuf, // Profiles pub lib_profile_dev: Option, @@ -197,6 +199,7 @@ impl ProjectConfig { fn parse(dir: &Utf8Path, metadata: &serde_json::Value, cargo_metadata: &Metadata) -> Result { let mut conf: ProjectConfig = serde_json::from_value(metadata.clone())?; conf.config_dir = dir.to_path_buf(); + conf.tmp_dir = cargo_metadata.target_directory.join("tmp"); let dotenvs = load_dotenvs(dir)?; overlay_env(&mut conf, dotenvs)?; if conf.site_root == "/" diff --git a/src/config/tailwind.rs b/src/config/tailwind.rs index 91a858c7..ea7449d9 100644 --- a/src/config/tailwind.rs +++ b/src/config/tailwind.rs @@ -7,6 +7,7 @@ use anyhow::{bail, Result}; pub struct TailwindConfig { pub input_file: Utf8PathBuf, pub config_file: Utf8PathBuf, + pub tmp_file: Utf8PathBuf, } impl TailwindConfig { @@ -26,9 +27,12 @@ impl TailwindConfig { .unwrap_or_else(|| Utf8PathBuf::from("tailwind.config.js")), ); + let tmp_file = conf.tmp_dir.join("tailwind.css"); + Ok(Some(Self { input_file, config_file, + tmp_file, })) } }