Scripts: coerce live reload port to integer#29196
Conversation
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @emilio-martinez! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
|
Thank you for your contribution. The proposed change makes sense. I had only a minor styling comment. Side note: Live reload will eventually get replaced by React Fast Refresh as explored in #28273. |
gziolo
left a comment
There was a problem hiding this comment.
Nice, it's ready to go. Thank you!
|
Congratulations on your first merged pull request, @emilio-martinez! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts: https://profiles.wordpress.org/me/profile/edit/ And if you don't have a WordPress.org account, you can create one on this page: https://login.wordpress.org/register Kudos! |
Description
Attempting to use
process.env.WP_LIVE_RELOAD_PORTwas not working for me. After some debugging, I realizedwebpack-livereload-pluginmust not expect to receive a port argument of astringtype, failing silently to take the desired port, and perprocess.envdocs:Additionally, the use of the logical OR operator would prevent passing a
0value, precluding the use of the followingwebpack-livereload-pluginfunctionality:This PR aims to remedy this by parsing
process.env.WP_LIVE_RELOAD_PORTbefore passing the value towebpack-livereload-plugin.How has this been tested?
Validated by running these changes against a local project. Before the change, running
wp-scripts startwould always log one of the two below:Live Reload listening on port 35729Live Reload disabled: listen EADDRINUSE: address already in use :::35729(for parallel processes run)After the changes in this PR, the appropriate port will be used — including the use of a
0value.Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: