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

Conversation

ponychicken
Copy link
Contributor

This article describes a new and useful feature in Live reload 1.5 and later.
I think it could make sense to enable it by default for new projects...

https://fly.io/phoenix-files/phoenix-dev-blog-server-logs-in-the-browser-console/

@SteffenDE
Copy link
Contributor

Thank you, @ponychicken! I think we'll need to add web_console_logger: true here as well:

config :my_app, MyAppWeb.Endpoint,
  live_reload: [
+   web_console_logger: true,
    patterns: [
      ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
      ~r"priv/gettext/.*(po)$",
      ~r"lib/my_app_web/(controllers|live|components)/.*(ex|heex)$"
    ]
  ]

@ponychicken
Copy link
Contributor Author

@SteffenDE
I think you meant the file installer/templates/phx_umbrella/apps/app_name_web/config/dev.exs right?

I pushed it.

Comment on lines 41 to 42
// connect if there are any LiveViews on the page
<%= @live_comment %>liveSocket.connect()
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

@SteffenDE SteffenDE merged commit f586988 into phoenixframework:main Nov 26, 2024
7 checks passed
@SteffenDE
Copy link
Contributor

Thank you! 🙌

SteffenDE added a commit that referenced this pull request Nov 26, 2024
SteffenDE added a commit that referenced this pull request Nov 26, 2024
This reverts commit f586988.

I didn't see #5799;
will go with that instead!
@josevalim
Copy link
Member

You had to revert it? Any particular reason?

@SteffenDE
Copy link
Contributor

I didn't see #5799 which also added a comment for the click to open functionality, so I went with that one instead.

@josevalim
Copy link
Member

Should we have it enabled by default in dev?

@SteffenDE
Copy link
Contributor

It is probably the better developer experience, so yeah, I think I'd be happy with doing it by default. I can send a PR :)

SteffenDE added a commit that referenced this pull request Nov 26, 2024
Relates to: #5799
Relates to: #5910

Co-authored-by: Rodolfo Carvalho <[email protected]>
Co-authored-by: ponychicken <[email protected]>
SteffenDE added a commit that referenced this pull request Nov 27, 2024
Relates to: #5799
Relates to: #5910

Co-authored-by: Rodolfo Carvalho <[email protected]>
Co-authored-by: ponychicken <[email protected]>
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.

3 participants