Skip to content
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

Also include priv/static/assets for live reload #3036

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

Tuxified
Copy link

@Tuxified Tuxified commented Mar 10, 2022

Hi 👋 ,

You asked on Discord why you the Live Reload doesn't work, so I played around a bit and this seems to have solved it for me (using a Linux machine):

Tailwind compiles the assets/CSS to priv/static/assets folder which wasn't included in the list of folders to watch for live_reload.
This change (together with installing inotify-tools) seems to trigger live reloading when CSS gets changed.

I also include a tiny change for the next person who tries to run it without setting up correct ENV vars beforehand

Hope it helps,
Tonći

Tailwind compiles the assets/CSS to priv/static/assets folder which wasn't included in the list of folders to watch for live_reload.
This change (together with installing inotify-tools) seems to trigger live reloading when CSS gets changed
Plug will complain the secret_key_base doesn't meet the minimum length
of 64 bytes if someone forgets to supply one via ENV variables
@samaaron
Copy link
Collaborator

samaaron commented Mar 10, 2022

Ah, interesting - I had taken a quick look at that and assumed that the matcher ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", would match priv/static/foo/bar/baz.png as the .* might have just considered the / as a standard character:

iex(4)> "/priv/static/assets/bar.js" =~ ~r"priv/static/.*(js|css)$"
true

Perhaps I'm misunderstanding things - I'm just guessing that the =~ operator (or equivalent) is used to match the patterns?

Still, I tried this - on my Windows dev machine - and it didn't affect things. .heex modifications trigger asset rebuild, .css modifications didn't. I then opened up my Mac, synced things up and found that thing happen to work perfectly there - both .css and .heex file mods trigger rebuilds without needing this change. Perhaps, for you, it was the installation of inotify-tools that fixed things?

I read that there might be some issues with tracking file changes on Windows when not running as an administrator - but it seems super weird that it should seemingly work with one type of file and not another. Perhaps there are issues having multiple watchers on Windows?

@samaaron
Copy link
Collaborator

Further to this, I just launched Sonic Pi from a Windows terminal running in Administrator mode and modifying a .css file did indeed trigger a rebuild of the assets. It almost certainly has something to do with Windows lack of symlinks.

@Tuxified
Copy link
Author

Hi Sam,

You're completely right, inotify-tools was actually all I needed, sorry for the confusion 🙈

I don't have access to a Windows machine so cannot check there, however digging through the deps list it seems https://github.com/falood/file_system is handling the cross-platform file watching and it mentions https://github.com/thekid/inotify-win as the inotify-tools port for Windows.

Hope that helps?

Shall I change this PR to just include the change to default secret_key_base? I'm also fine with closing this PR if it doesn't add anything :)

@samaaron
Copy link
Collaborator

@Tuxified no worries at all. I really don't know what I'm doing and it's all guess work on my behalf from trying to read the source.

I do think that a PR with the default secret key base change makes a lot of sense though - thanks for noticing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants