-
-
Notifications
You must be signed in to change notification settings - Fork 272
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
HTML templates reloading issue (TailwindCSS) #30
Comments
Hi, The HTML files would still be related to Django btw, it would be really interesting if py files worked but html didn't. Do the CSS and JS watchers show that files were updated when you make a change by notifying you in the terminal? It should say it was rebuilt. |
No, upon saving/modifying an HTML file it does not show up on the log "Rebuilding... Done in XXXms". However when I modify a Python file (views.py let's say) it does reload/update, logging this to the console:
This is the log upon starting the container:
|
Have you tried visiting the page and reloading? It might not show up in the terminal but it should update. The CSS looks like it's reloading based on this:
Have you tried doing a hard reload in your browser to clear any cache? |
I visited and reloaded after each modification and save. Not working.
Yes, the worker starts up fine and does the first build just fine, but not subsequent.
Just tried, same result (no HTML/CSS update) |
Is your source code living inside of WSL 2's file system or is it mounted from a drive in Windows? I would say try putting it inside of WSL 2's file system, not only may it fix this issue but it's also going to be way way faster. This is how I run things too for reference. |
Do you have |
Yes. All of those are identical in the .env
docker-compose.yml
tailwind.config.js
Also, within the
|
This is a tricky one to debug because my set up is nearly the same as you. I also use WSL 2 with Windows 10 and the files are within WSL 2's file system and everything is working. I also haven't seen this pop up for anyone else yet. I don't think this will make a difference but can you |
I installed BUT if I modify the The issue therefore seems to be on the watch of HTML files. IDK if there are issues with the paths, maybe.. |
Do you have the same issue with https://github.com/nickjj/docker-flask-example? It has the same set up as this Django app but for Flask. It also uses Gunicorn too. This could help reduce the problem down if it happens to work with the Flask example app. |
I just tried it and yes, it has the same issue. Might have something to do w/ caching/gunicorn? |
We can double check that with https://github.com/nickjj/docker-rails-example if you're up for it, which is the same example app but with Rails. It doesn't use Gunicorn. |
I spin up the rails container and sadly, the CSS watch does not work either. I went back and within the css container terminal I ran At this point I think it might have something to do with my system. Edit: yea I thought so. I'm editing in Vim inside the WSL though, not using windows programs to edit. |
That issue you linked is when you volume mount in files from You could still open files in WSL 2 with VSCode, Sublime Text or any other editor that's installed on Windows. |
FWIW here's my WSL status log output:
It must definitely be my system. |
I have been tinkering with some other WSL installs and I think I spotted a lead as to why it doesn't refresh. I made a clean install of WSL Ubuntu, and went straight into cloning the repo and running with.a.clean.install.and.nano.it.works.mp4But when I tried to do the same with Vim, and saved, it stopped working. Worse, something broke, and now if I try to use Nano to edit, it does not watch the .html files anymore. the.moment.i.save.with.vim.it.stops.working.mp4Hope this sheds some light on the issue. |
Are you editing the file in WSL 2 or did you install Vim inside of the container? For reference my copy of Vim is installed directly in WSL 2. There's no editors installed in the container. |
Editing in WSL2, Vim was not installed as it was already in the distro (Ubuntu). So the same as yours. Something "locks" the watch when Vim saves the file, as you can see. Nano had no issues until the file was saved in Vim. |
That is good detective work, at least we know it's mostly a localized issue. Do you have any "interesting" Vim plugins or settings that might affect how files are saved? My vimrc is at https://github.com/nickjj/dotfiles/blob/master/.vimrc, I'm not doing anything too crazy tho. The only thing that stands out is I have |
It seems I'm not the only one to have this issue (see guard/listen#434 and https://github.com/guard/guard/wiki/Analysis-of-inotify-events-for-different-editors#vim) I'll try your suggestion and these later on, see if I can get it to work. |
Playing around with inotifywait, it seems that the access method to the file impacts the --watch capabilities, and throws the worker off. When opening an html template with Vim/Neovim, then saving:
(no log upon opening the file) When opening with Nano:
When saving the file with Nano:
I am certain this behavior is what is causing the issue. Do you have any guesses as to what should be modified? |
I used VSCode via WSL and what do you know, the CSS watcher now works. It was all Vim/Neovim, after all. Would you mind sharing your config, specially options related to file saving behavior/swaps? I'd like to keep using Neovim but I can settle with VSCode. |
My full vimrc is here: https://github.com/nickjj/dotfiles/blob/master/.vimrc, I'm using Vim 8.1 at the moment. I'm not sure what would cause this exactly but Googling for "vim inotify save" comes up with a bunch of things such as https://vi.stackexchange.com/a/25031. In a previous comment I suggested trying to set |
Hi, I think this ended up being a bug with TailwindCSS, version v3.2.4 has a fix and tailwindlabs/tailwindcss#7759 has a bunch of comments around file watching not working with earlier v3.2.X releases when using Vim. I'm able to confirm that 3.2.1 won't reload CSS files but 3.2.4 does. This project is already set up to use 3.2.4 but it wasn't at the time when this issue was opened, but earlier 3.1.X releases didn't have this issue. |
@nickjj Nicely spotted. Thank you very much for the heads up! |
@adrivn Any update on this? Having the same problem. And using Tailwind v3.2.7 so it doesn't seem to be that. |
Are you running Django with Also if you're using WSL 2, make sure your files are in WSL 2's file system instead of being mounted through a Windows drive. |
@nickjj Yes, all are set correctly in the Also just cloned the repo on my M1 Mac, and editing HTML templates and reloading doesn't work there either, still need to stop and compose again. Editing CSS works just fine. |
@sdevgill I'm able to reproduce this. I personally run WSL 2 too and this project absolutely worked a few weeks ago but I'm noticing that HTML templates aren't reloading as of today. |
I've opened a new issue to track this at: #36 Thanks for the report! |
Hello Nick,
First off, thank you loads for the work you put into this bundle, you have inspired me greatly to dive into Docker and containerization.
The issue at hand relates to hot reloading while developing. I find that whenever I modify a *.py file the webapp reloads just fine, showing the changes instantaneously. This is not the case when its an *.html template being modified. The css and js watchers are up and running. I checked the tailwind.config.js file and its pointing to the app folder, recursively and gathering all *.html files, so I don't know where to look now.
Thank you
The text was updated successfully, but these errors were encountered: