-
Notifications
You must be signed in to change notification settings - Fork 201
Add a new --live-reload
parameter to the theme serve
command
#1871
Conversation
👋 Hi, @MeredithCastile! :) This PR introduces a new flag for the Currently, the live-reload mechanism has only a single mode (
However, some advanced users prefer to deactivate the mechanism above because they have custom tooling to auto-refresh the page. Other partners prefer to refresh the entire page always. For handling these needs, the
I personally like this terminology, but I'm not sure if this is the best one we can achieve for partners. What do you think about it? :) Thanks! 🚀 |
Yes, those seem okay to me. You might consider exploring whether the word "mode" is necessary. I go back and forth on that. You might consider, too, changing "full" to "full-page." To make it more intuitively graspable. Suggestion, then:
As always, we should have this in our help and documentation. |
Rename `full` to `full-page` Rename `none` to `off`
--live-reload-mode
parameter to the theme serve
command--live-reload
parameter to the theme serve
command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks right to me, other than comments.
Not too sure if we should rename "fast" to "hot reload". The feature is mentioned in the doc as "hot reload": https://shopify.dev/themes/tools/cli/theme-commands#serve. What do you think?
Rename `__SHOPIFY_DEV_MODE_ENV__` to `__SHOPIFY_CLI_ENV__`
Thanks for the review, @macournoyer! Great suggestions, "hot reload" is more expressive than "fast"! I've updated the PR description and applied the changes/fixes in a new commit. Thanks! |
Thanks a lot for reporting this and for sharing the stack, @notrealdev! You may work around this issue by using the
Still, I've just opened a PR fixing this issue #2092, so you will be able to use the equal sign again in the next CLI version. We've done extensive work in the parameters parser to support glob parameters (#2066), which recently introduced that issue. |
WHY are these changes introduced?
Some users prefer to fully the reload page (I) when a file is modified, instead of relying on the hot reload mechanism that updates sections individually (II). Also, other users have their own tooling for refreshing the page, so they need to deactivate any refresh mechanism (III) entirely.
This PR introduces the
--live-reload
with three modes: I) full-page, II) hot-reload (default), and III) off.WHAT is this pull request doing?
Main change
The new parameter (
--live-reload
) in theTheme::Command::Serve
has three valid values:hot-reload
- it's the current approachfull-page
- every time users perform a file change, the page is refreshed entirelyoff
- the page is never automatically updated (thehot-reload.js#connect
function is never called)The
ShopifyCLI::Theme::DevServer::ReloadMode
class works like an enum and validates the parameter value when theServe
command callsReloadMode.get
.The
mode
value is injected into the page with thehot-reload.js
at theShopifyCLI::Theme::DevServer::HotReload
level. So, the parameter controls how the page refreshes in the client-side.ShopifyCLI::Context change
Following the error/try-this convention introduced here, this PR introduces the
ShopifyCLI::Context.abort(error_message, help_message = nil)
API.Now the
abort
API has an optional help message, which appears in the Try this frame.How to test your changes?
Run
shopify theme serve --live-reload=<MODE>
with different reload modes and notice how the page behaves differently for each one:shopify theme serve --live-reload=hot-reload
shopify theme serve --live-reload=full-page
shopify theme serve --live-reload=off
shopify theme serve
(fast as the default)shopify theme serve --live-reload=other
Post-release steps
Update documentation with
shopify theme serve
parameters: shopify.dev/themes/tools/cli/theme-commands#serve.Update checklist