From 10eda3a7944880a43671b80e4f15d5070e5809ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Shosh=C3=A1na=20Abigail?= <72781354+LilahTovMoon@users.noreply.github.com> Date: Fri, 16 Jan 2026 21:01:00 -0500 Subject: [PATCH] respect tailwind_input when detecting tailwind v3 or v4 (#5151) * respect tailwind_input when detecting tailwind v3 or v4 * cargo fmt fixes --- packages/cli/src/tailwind.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/cli/src/tailwind.rs b/packages/cli/src/tailwind.rs index f81c31029..f668f64ed 100644 --- a/packages/cli/src/tailwind.rs +++ b/packages/cli/src/tailwind.rs @@ -24,7 +24,7 @@ impl TailwindCli { input_path: Option, output_path: Option, ) -> Result<()> { - let Some(tailwind) = Self::autodetect(&manifest_dir) else { + let Some(tailwind) = Self::autodetect(&manifest_dir, &input_path) else { return Ok(()); }; @@ -54,7 +54,7 @@ impl TailwindCli { output_path: Option, ) -> tokio::task::JoinHandle> { tokio::spawn(async move { - let Some(tailwind) = Self::autodetect(&manifest_dir) else { + let Some(tailwind) = Self::autodetect(&manifest_dir, &input_path) else { return Ok(()); }; @@ -81,16 +81,22 @@ impl TailwindCli { /// /// Note that v3 still uses the tailwind.css file, but usually the accompanying js file indicates /// that the project is using v3. - pub(crate) fn autodetect(manifest_dir: &Path) -> Option { - if manifest_dir.join("tailwind.config.js").exists() { + pub(crate) fn autodetect(manifest_dir: &Path, input_path: &Option) -> Option { + let dir = input_path + .as_ref() + .map(|p| manifest_dir.join(p)) + .and_then(|p| p.parent().map(|parent| parent.to_path_buf())) + .unwrap_or(manifest_dir.to_path_buf()); + + if dir.join("tailwind.config.js").exists() || dir.join("tailwind.config.ts").exists() { return Some(Self::v3()); } - if manifest_dir.join("tailwind.config.ts").exists() { - return Some(Self::v3()); - } - - if manifest_dir.join("tailwind.css").exists() { + if input_path + .as_ref() + .map(|p| manifest_dir.join(p).exists()) + .unwrap_or_else(|| manifest_dir.join("tailwind.css").exists()) + { return Some(Self::v4()); }