phoenixframework / phoenix_live_reload

Provides live-reload functionality for Phoenix
MIT License
313 stars 90 forks source link

Live reload not triggering #134

Open mfeckie opened 1 year ago

mfeckie commented 1 year ago

Version: {:phoenix_live_reload, "~> 1.2", only: :dev}

I have components in this folder lib/cockpit_web/components

with the following config for live_reload

  live_reload: [
    patterns: [
      ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
      ~r"lib/cockpit_web/(components|live|views)/.*(ex)$",
      ~r"lib/cockpit_web/templates/.*(eex)$"
    ]
  ]

Saving files in the components folder, such as lib/cockpit_web/components/common.ex does not trigger a rebuild

Saving files in the live folder does. lib/cockpit_web/live/deployments_live.ex

I can't seem to figure out why this is the case and would love some insights into what I'm doing wrong

ellismarkf commented 1 year ago

Is it that the browser doesn't reload, or that saving doesn't trigger a rebuild?

I ran into an issue where saving would trigger a rebuild, but the browser wouldn't refresh until I manually reloaded the page, even for CSS changes in template files. If that's the issue you're seeing, make sure that your root.html.heex has a body html tag in it. I had moved the body tag to a different layout file, and that's when the browser refresh stopped working.

Based on this line it seems like the plug expects an HTML document with a body tag for it to work. @chrismccord is that true? Wonder if that's something that could be optionally configured?

Might be worth mentioning at least in the README, so noobs like me don't make that mistake 😂 Happy to open a PR if you think it's worth the effort!

wodow commented 10 months ago

it seems like the plug expects an HTML document with a body tag for it to work

Excellent find, @ellismarkf . Thank you -- saved me some serious debugging.

I will add a specific issue to warn on this, since this one is broader.