Created
March 3, 2024 22:14
-
-
Save M-Drummond/5dda0fb71f0b8f6d9ff85ff48a2a3f6c to your computer and use it in GitHub Desktop.
Wordpress + ViteJS
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
function vite_scripts() { | |
// wp-config needs: define( 'FRONTEND_DEV_MODE' , true ); added | |
if ( FRONTEND_DEV_MODE ) { | |
echo '<!-- vite time --> | |
<script type="module" src="https://localhost:3000/@vite/client"></script> | |
<script type="module" src="https://localhost:3000/src/js/app.ts"></script> | |
' ; | |
} else { | |
echo ' | |
<link rel="stylesheet" href="' . get_stylesheet_directory_uri() . '/dist/assets/app.css?v=1.0" /> | |
<script type="module" src="' . get_stylesheet_directory_uri() . '/dist/assets/app.js?v=1.0"></script> | |
'; | |
} | |
} | |
add_action('wp_head', 'vite_scripts'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment