-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scripts: Enable React Fast Refresh for block development (#28273)
* Scripts: Enable React Fast Refresh for block development * Externalize React Refresh to make it work without Dev Tools
- Loading branch information
1 parent
649b493
commit bcc8ec7
Showing
11 changed files
with
1,571 additions
and
416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,7 +208,8 @@ function gutenberg_register_vendor_scripts( $scripts ) { | |
$scripts, | ||
'react', | ||
'https://unpkg.com/[email protected]/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, | ||
|
@@ -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. | ||
|
Oops, something went wrong.