fix(build): always regenerate CSS on every cargo build
Remove all rerun-if-changed directives so Cargo runs the build script unconditionally, ensuring tailwindcss always regenerates styles.css without manual steps.
This commit is contained in:
parent
b68748da14
commit
db786c8387
1 changed files with 0 additions and 33 deletions
33
build.rs
33
build.rs
|
|
@ -15,23 +15,9 @@ fn git_hash() {
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let hash = output.trim();
|
let hash = output.trim();
|
||||||
println!("cargo:rustc-env=GIT_HASH={hash}");
|
println!("cargo:rustc-env=GIT_HASH={hash}");
|
||||||
println!("cargo:rerun-if-changed=.git/HEAD");
|
|
||||||
println!("cargo:rerun-if-changed=.git/refs/heads/");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tailwind() {
|
fn tailwind() {
|
||||||
// Rerun when any template or static file changes
|
|
||||||
for entry in walkdir("templates") {
|
|
||||||
println!("cargo:rerun-if-changed={entry}");
|
|
||||||
}
|
|
||||||
for entry in walkdir("static") {
|
|
||||||
// Skip the generated output file to avoid circular rebuilds
|
|
||||||
if entry == "static/css/styles.css" {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
println!("cargo:rerun-if-changed={entry}");
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut cmd = Command::new("tailwindcss");
|
let mut cmd = Command::new("tailwindcss");
|
||||||
cmd.args(["-i", "static/css/input.css", "-o", "static/css/styles.css"]);
|
cmd.args(["-i", "static/css/input.css", "-o", "static/css/styles.css"]);
|
||||||
|
|
||||||
|
|
@ -52,22 +38,3 @@ fn tailwind() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn walkdir(dir: &str) -> Vec<String> {
|
|
||||||
let mut files = Vec::new();
|
|
||||||
let mut stack = vec![std::path::PathBuf::from(dir)];
|
|
||||||
while let Some(path) = stack.pop() {
|
|
||||||
let Ok(entries) = std::fs::read_dir(&path) else {
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
for entry in entries.flatten() {
|
|
||||||
let path = entry.path();
|
|
||||||
if path.is_dir() {
|
|
||||||
stack.push(path);
|
|
||||||
} else {
|
|
||||||
files.push(path.display().to_string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
files
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue