Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Phoenix Code_Reloader Only Reload Elixir Code?

This came up as a result of a question that someone else asked.

Looking at the documentation for Phoenix.CodeReloader it looks like this solely reloads Elixir code. Is that correct? If so, what does phoenix_live_reload do? Does live reload also take care of reloading static pages and/or JS resources?

I'd just like to understand the difference between the two settings and in which use cases one is appropriate versus using the other.

like image 289
Onorio Catenacci Avatar asked Jan 13 '16 17:01

Onorio Catenacci


1 Answers

Phoenix.CodeReloader is responsible for reloading the code in the web directory (and lib as of Phoenix 1.2). This means that if you change a something in web (such as a controller) then the Elixir code will be reloaded and used on your next request. You specify external watchers (such as brunch or webpack) in your Endpoint for non-elixir code.

The phoenix_live_reload project adds a plug which injects some JavaScript into your page with a WebSocket connection to the server. When you make a change to anything in your config for live_reload (JavaScript, stylesheets, templates and views by default) then the page will be reloaded in response to a message sent via the WebSocket. If the change was to an Elixir file then it will be recompiled and served when the page is reloaded. If it is JavaScript or CSS then it will be handled by the watchers (brunch by default.)

like image 176
Gazler Avatar answered Sep 16 '22 17:09

Gazler