Closed mathrick closed 8 months ago
I've removed the use of tailwindcss -w
, since it never worked reliably, and it doesn't really make sense to use it in the first place. We already have a watcher built in.
Is there anything else you'd like to see for this PR to be acceptable?
Is there anything else you'd like to see for this PR to be acceptable?
Since you removed the tailwind live server, does it work in dev mode? Can it update the stylesheet on class changes? I just didn't find the time to verify it myself
Since you removed the tailwind live server, does it work in dev mode? Can it update the stylesheet on class changes? I just didn't find the time to verify it myself
Yes, I use it primarily in dev mode. It actually works better now, because the tailwind watcher no longer leaks memory, and it's more reliable. I believe the watcher would previously race lektor sometimes and not get everything updated. I've not had that happen since I removed -w
, it's now very solid.
@mathrick Can you check the failing tests?
@frostming will do
@frostming: fixed, could you retry?
I've been running into weird timeouts in test_server_rebuilds_css_when_input_css_updated()
that I really can't see any reason for, and it shouldn't be any of my changes anyway. I had it pass once for no visible reason and then it went back to timing out, so I'm hoping it will just not do that when run through GitHub.
This is really weird: for some reason, writing the sentinel value in test_server_rebuilds_css_when_input_css_updated()
does not trigger a rebuild. But if I watch the test and manually change the file from another terminal before the timeout hits, the server happily picks up the change.
To make things even weirder, this does not happen if I enter the debugger from within pytest. Which makes me think this is some odd artefact of how the server is run within the tests, and also makes it incredibly difficult to debug. Maybe something with buffering? But I'm not sure what would be buffered exactly that could cause that.
Alright, this was extremely painful to debug, but I finally found the issue. To quote from the commit message:
This was caused by the switch from having two watchers (lektor server and tailwindcss) to just the server. Because we made writes as soon as wait_for_server() returns, this would essentially catch the server in a short window before it was done returning from a build, and it wouldn't pick up the changes, so the rebuild would never happen. Previously this was not a concern, because the CSS was watched by one process, and other files by the other, and they delayed each other, so there was never a chance to write immediately after the rebuild was done. Now we sleep for a second before writing to prevent that.
Note that this is purely an artefact of the testing process, and the fact we can do it within milliseconds. This is not possible for a human, so it doesn't come up in normal usage.
Run tailwindcss on the build dir, rather than input templates, so that dynamically-generated values are properly seen by tailwind.
Fixes #7.