-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support dynamic (Jinja-generated) classes #8
Conversation
lektor_tailwind.py
Outdated
subprocess.run( | ||
[ | ||
self.tailwind_bin, | ||
"-i", | ||
self.input_css, | ||
"-o", | ||
os.path.join(output_path, self.css_path), | ||
"--minify", | ||
], | ||
self._get_tailwind_args(output_path, "--minify"), | ||
check=True, | ||
cwd=self.env.root_path, | ||
cwd=output_path, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this method is run before_build
, I doubt if it works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, fixed.
48e17ce
to
51ac918
Compare
Run tailwindcss on the build dir, rather than input templates, so that dynamically-generated values are properly seen by tailwind.
51ac918
to
3bc397b
Compare
Running Tailwind watcher from within Lektor watcher is unnecessary, since we already have a watcher and know when to rebuild things, and it leads to bugs, such as the Tailwind watcher leaking memory or kicking in before the build is fully done.
b5900ee
to
df89f8a
Compare
I've removed the use of |
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 |
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 |
@mathrick Can you check the failing tests? |
@frostming will do |
@frostming: fixed, could you retry? I've been running into weird timeouts in |
This is really weird: for some reason, writing the sentinel value in |
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. |
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.
Alright, this was extremely painful to debug, but I finally found the issue. To quote from the commit message:
|
Run tailwindcss on the build dir, rather than input templates, so that dynamically-generated values are properly seen by tailwind.
Fixes #7.