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

Reload the page after webpack watch compile #3871

Merged
merged 6 commits into from
Jun 2, 2018
Merged

Reload the page after webpack watch compile #3871

merged 6 commits into from
Jun 2, 2018

Conversation

atimmer
Copy link
Member

@atimmer atimmer commented Dec 8, 2017

I tried implementing webpack-dev-server but that I didn't crack that this time. This PR will at least save everyone some F5/Ctrl+R keystrokes.

Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

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

I'd occasionally find it useful to keep an outdated version of an editor tab active for comparison's sake, but not often enough that this would disrupt my typical workflow.

I do worry a bit since Webpack rebuilds can be very noisy that we could encounter annoyances around unexpected reloads.

Generally I'd be okay with something like this though.

I tried implementing webpack-dev-server but that I didn't crack that this time.

Can you elaborate on the issues you were encountering?

@@ -177,6 +177,13 @@ function gutenberg_register_scripts_and_styles() {
filemtime( gutenberg_dir_path() . 'blocks/build/edit-blocks.css' )
);
wp_style_add_data( 'wp-edit-blocks', 'rtl', 'replace' );

if ( WP_DEBUG ) {
Copy link
Member

Choose a reason for hiding this comment

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

Would SCRIPT_DEBUG be the more appropriate constant here? Based on the description, it seems primarily aimed at toggling minified version, so perhaps not.

https://codex.wordpress.org/Debugging_in_WordPress#SCRIPT_DEBUG

@atimmer
Copy link
Member Author

atimmer commented Dec 12, 2017

@aduth Because WordPress itself is served by a different web server you have to proxy every request. Once I had that in place I didn't get any further. Webpack dev server wouldn't show console messages that it is trying to reload and the page wouldn't reload at all. (I would also like to add that I have never manually set up a Webpack configuration, so I might not be the best person to take a crack at this. I have asked @xyfi to take another look once he's back from vacation.

If you want we could implement a new Gutenberg specific constant like GUTENBERG_LIVE_RELOAD which could be used to disable live reload.

@atimmer
Copy link
Member Author

atimmer commented Jan 5, 2018

This is ready for review.

Live reloading can now be enabled by setting the GUTENBERG_LIVE_RELOAD constant to true. Any value other than true will be used as the URL to load. This can be used to customize the URL.

I've also made it possible to customize the port that the livereloading server uses. This is useful when multiple projects support livereloading. This is used like so: GUTENBERG_LIVE_RELOAD_PORT=35730 yarn dev.

@gziolo gziolo added Framework Issues related to broader framework topics, especially as it relates to javascript [Type] Build Tooling Issues or PRs related to build tooling labels May 10, 2018
@gziolo
Copy link
Member

gziolo commented May 10, 2018

@atimmer - it was accepted and seems to be useful, can you update and merge? I like that it is optional 👍

@gziolo gziolo added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label May 10, 2018
@gziolo gziolo requested a review from pento May 16, 2018 10:30
@gziolo
Copy link
Member

gziolo commented May 16, 2018

This could also be helpful to include some note how to use it in CONTRIBUTING document.

@pento
Copy link
Member

pento commented May 17, 2018

I'm cool with this going in, but I'd want to actually build some stuff with it enabled before we start recommending it to all contributors.

@atimmer atimmer merged commit 23f8945 into WordPress:master Jun 2, 2018
@atimmer atimmer deleted the add/webpack-live-reload branch June 2, 2018 16:32
@mtias mtias added this to the 3.0 milestone Jun 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Framework Issues related to broader framework topics, especially as it relates to javascript [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. [Type] Build Tooling Issues or PRs related to build tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants