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

Scripts: Enable React Fast Refresh for block development #28273

Merged
merged 2 commits into from
Dec 14, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 2 additions & 19 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ function gutenberg_register_vendor_scripts( $scripts ) {
$scripts,
'react',
'https://unpkg.com/react@17.0.1/umd/react' . $react_suffix . '.js',
array( 'wp-polyfill' )
// See https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/docs/TROUBLESHOOTING.md#externalising-react.
SCRIPT_DEBUG ? array( 'wp-react-refresh-entry', 'wp-polyfill' ) : array( 'wp-polyfill' )
);
gutenberg_register_vendor_script(
$scripts,
Expand Down Expand Up @@ -484,24 +485,6 @@ function gutenberg_register_packages_styles( $styles ) {
}
add_action( 'wp_default_styles', 'gutenberg_register_packages_styles' );

/**
* Registers common scripts and styles to be used as dependencies of the editor
* and plugins.
*
* @since 0.1.0
*/
function gutenberg_enqueue_block_editor_assets() {
if ( defined( 'GUTENBERG_LIVE_RELOAD' ) && GUTENBERG_LIVE_RELOAD ) {
$live_reload_url = ( GUTENBERG_LIVE_RELOAD === true ) ? 'http://localhost:35729/livereload.js' : GUTENBERG_LIVE_RELOAD;

wp_enqueue_script(
'gutenberg-live-reload',
$live_reload_url
);
}
}
add_action( 'enqueue_block_editor_assets', 'gutenberg_enqueue_block_editor_assets' );

/**
* Retrieves a unique and reasonably short and human-friendly filename for a
* vendor script based on a URL and the script handle.
Expand Down