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

Enable web console logger for new projects #5910

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions installer/templates/phx_assets/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ import "phoenix_html"
<%= @live_comment %>window.addEventListener("phx:page-loading-start", _info => topbar.show(300))
<%= @live_comment %>window.addEventListener("phx:page-loading-stop", _info => topbar.hide())

// Enable server log streaming to client.
<%= @live_comment %>window.addEventListener("phx:live_reload:attached", ({detail: reloader}) => {
<%= @live_comment %> reloader.enableServerLogs()
<%= @live_comment %> window.liveReloader = reloader
<%= @live_comment %>})
// connect if there are any LiveViews on the page
<%= @live_comment %>liveSocket.connect()
Comment on lines 41 to 42
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we also need to enable the "click to open" component thingy? Or is that enabled by default?

Copy link
Contributor Author

@ponychicken ponychicken Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using this branch, i cd installer and ran mix phx.new dev_app --dev
After installing deps, adding a live view and starting the server i am able to see the web console logs without additional steps.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I meant to say that there are more features we should add by default. Mostly a reminder to @chrismccord :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not enabled by default, but we can accept a separate PR for it.

https://github.com/phoenixframework/phoenix_live_reload#jumping-to-heex-function-definitions


Expand Down
1 change: 1 addition & 0 deletions installer/templates/phx_single/config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ config :<%= @app_name %>, <%= @endpoint_module %>,
# Watch static and templates for browser reloading.
config :<%= @app_name %>, <%= @endpoint_module %>,
live_reload: [
web_console_logger: true,
patterns: [
~r"priv/static/(?!uploads/).*(js|css|png|jpeg|jpg|gif|svg)$",<%= if @gettext do %>
~r"priv/gettext/.*(po)$",<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ config :<%= @web_app_name %>, <%= @endpoint_module %>,
# Watch static and templates for browser reloading.
config :<%= @web_app_name %>, <%= @endpoint_module %>,
live_reload: [
web_console_logger: true,
patterns: [
~r"priv/static/(?!uploads/).*(js|css|png|jpeg|jpg|gif|svg)$",<%= if @gettext do %>
~r"priv/gettext/.*(po)$",<% end %>
Expand Down