1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use std::path::Path;
fn main() {
println!("cargo:rerun-if-changed=ui-src/input.css");
println!("cargo:rerun-if-changed=ui/index.html");
// Locate the Tailwind standalone binary for the current platform.
// Download the right binary and drop it next to Cargo.toml:
// macOS arm64 → tailwindcss-macos-arm64
// macOS x86_64 → tailwindcss-macos-x64
// Linux arm64 → tailwindcss-linux-arm64
// Linux x86_64 → tailwindcss-linux-x64
// Windows x64 → tailwindcss-windows-x64.exe
let binary = if cfg!(target_os = "windows") {
"tailwindcss-windows-x64.exe"
} else if cfg!(target_os = "macos") {
if cfg!(target_arch = "aarch64") {
"tailwindcss-macos-arm64"
} else {
"tailwindcss-macos-x64"
}
} else if cfg!(target_arch = "aarch64") {
"tailwindcss-linux-arm64"
} else {
"tailwindcss-linux-x64"
};
// Generic fallback: a binary simply named "tailwindcss" in src-tauri/
let path = if Path::new(binary).exists() {
binary
} else if Path::new("tailwindcss").exists() {
"tailwindcss"
} else {
tauri_build::build();
return;
};
let status = std::process::Command::new(path)
.args(["-i", "ui-src/input.css", "-o", "ui/styles.css", "--minify"])
.status();
if let Ok(s) = status {
if !s.success() {
eprintln!("cargo:warning=Tailwind CSS build failed");
}
}
tauri_build::build()
}