Skip to content

Commit ad94a2c

Browse files
authored
⚡️ Check that tailwind output css actually changed before broadcasting updates. (#146)
* fix: check that output css file has changes on tailwind watch output * corrected output file path
1 parent 67e97b4 commit ad94a2c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/lustre_dev_tools/bin/tailwind.gleam

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,21 @@ pub fn watch(
266266
//
267267
// Fortunately (?) Tailwind's output only really tells is it rebuilt and
268268
// nothing else so there's no data we'd need to parse out anyway.
269-
on_unknown: handle_change,
269+
on_unknown: fn() {
270+
// Check that the output file has actually been modified before resending assets
271+
let file_info = simplifile.file_info(output <> ".css")
272+
case file_info {
273+
Ok(info) -> {
274+
case info.mtime_seconds > info.atime_seconds {
275+
True -> handle_change()
276+
False -> Nil
277+
}
278+
}
279+
Error(_e) -> {
280+
cli.log("Failed to locate output css file", quiet)
281+
}
282+
}
283+
},
270284
)
271285
|> result.replace_error(error.CouldNotStartFileWatcher(
272286
watcher: path,

0 commit comments

Comments
 (0)