Created
September 29, 2023 15:36
-
-
Save terrylinooo/d0f88d699536d1b9cd00f7c683d2adf7 to your computer and use it in GitHub Desktop.
functions.php
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
/** | |
* Print Vite dev server script tag. | |
* | |
* @package ironman | |
* @since 1.0.0 | |
*/ | |
function ironman_vite_dev_script() { | |
if ( | |
! defined( 'VITE_ENV' ) || | |
! defined( 'VITE_DEV_SERVER' ) || | |
constant( 'VITE_ENV' ) !== 'development' | |
) { | |
return; | |
} | |
$entry_file = constant( 'VITE_DEV_SERVER' ) . '/vite.entry.js'; | |
// phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript | |
echo '<script type="module" crossorigin src="' . esc_attr( $entry_file ) . '"></script>'; | |
} | |
add_action( 'wp_head', 'ironman_vite_dev_script' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment