Skip to content

Commit

Permalink
enable live reload features by default for new LV apps (#5986)
Browse files Browse the repository at this point in the history
Relates to: #5799
Relates to: #5910

Co-authored-by: Rodolfo Carvalho <[email protected]>
Co-authored-by: ponychicken <[email protected]>
  • Loading branch information
3 people authored Nov 27, 2024
1 parent 8bcf808 commit d34efa8
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions installer/templates/phx_assets/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,38 @@ import "phoenix_html"
// >> liveSocket.disableLatencySim()
<%= @live_comment %>window.liveSocket = liveSocket

// Uncomment the lines below to enable quality of life phoenix_live_reload
// The lines below enable quality of life phoenix_live_reload
// development features:
//
// 1. stream server logs to the browser console
// 2. click on elements to jump to their definitions in your code editor
//
// if (process.env.NODE_ENV === "development") {
// window.addEventListener("phx:live_reload:attached", ({detail: reloader}) => {
// // Enable server log streaming to client.
// // Disable with reloader.disableServerLogs()
// reloader.enableServerLogs()
//
// // Open configured PLUG_EDITOR at file:line of the clicked element's HEEx component
// //
// // * click with "c" key pressed to open at caller location
// // * click with "d" key pressed to open at function component definition location
// let keyDown
// window.addEventListener("keydown", e => keyDown = e.key)
// window.addEventListener("keyup", e => keyDown = null)
// window.addEventListener("click", e => {
// if(keyDown === "c"){
// e.preventDefault()
// e.stopImmediatePropagation()
// reloader.openEditorAtCaller(e.target)
// } else if(keyDown === "d"){
// e.preventDefault()
// e.stopImmediatePropagation()
// reloader.openEditorAtDef(e.target)
// }
// }, true)
//
// window.liveReloader = reloader
// })
// }
<%= @live_comment %>if (process.env.NODE_ENV === "development") {
<%= @live_comment %> window.addEventListener("phx:live_reload:attached", ({detail: reloader}) => {
<%= @live_comment %> // Enable server log streaming to client.
<%= @live_comment %> // Disable with reloader.disableServerLogs()
<%= @live_comment %> reloader.enableServerLogs()
<%= @live_comment %>
<%= @live_comment %> // Open configured PLUG_EDITOR at file:line of the clicked element's HEEx component
<%= @live_comment %> //
<%= @live_comment %> // * click with "c" key pressed to open at caller location
<%= @live_comment %> // * click with "d" key pressed to open at function component definition location
<%= @live_comment %> let keyDown
<%= @live_comment %> window.addEventListener("keydown", e => keyDown = e.key)
<%= @live_comment %> window.addEventListener("keyup", e => keyDown = null)
<%= @live_comment %> window.addEventListener("click", e => {
<%= @live_comment %> if(keyDown === "c"){
<%= @live_comment %> e.preventDefault()
<%= @live_comment %> e.stopImmediatePropagation()
<%= @live_comment %> reloader.openEditorAtCaller(e.target)
<%= @live_comment %> } else if(keyDown === "d"){
<%= @live_comment %> e.preventDefault()
<%= @live_comment %> e.stopImmediatePropagation()
<%= @live_comment %> reloader.openEditorAtDef(e.target)
<%= @live_comment %> }
<%= @live_comment %> }, true)
<%= @live_comment %>
<%= @live_comment %> window.liveReloader = reloader
<%= @live_comment %> })
<%= @live_comment %>}
<% end %>

0 comments on commit d34efa8

Please sign in to comment.