Created
October 17, 2019 10:42
-
-
Save panayotoff/adf452417f477ab7277bfa1a830d6906 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// https://medium.com/@romualdasromasdakeviius/using-vue-cli-to-build-wordpress-plugin-including-hmr-1a71dfdf05c2 | |
// https://medium.com/@devs_group/wordpress-vue-js-with-webpack-and-hot-reload-7c4faea9d0d9 | |
function is_develop_serve() | |
{ | |
$connection = @fsockopen('localhost', '8080'); | |
return $connection ? true : false; | |
} | |
function cwp_scripts() { | |
if(is_develop_serve()){ | |
wp_enqueue_style('cwp-style_dev', 'http://localhost:8080/css/app.css', [], null, 'all'); | |
wp_enqueue_script( 'cwp-app_dev', 'http://localhost:8080/js/app.js', [], null, false ); | |
} else { | |
// TODO: Add file hashing | |
wp_enqueue_style('cwp-style', get_asset('css/app.css'), [], null, 'all'); | |
wp_enqueue_script( 'cwp-libs', get_asset('js/chunk-vendors.js'), [], null, true ); | |
wp_enqueue_script( 'cwp-app', get_asset('js/app.js'), ['cwp-libs'], null, true ); | |
} | |
} | |
add_action( 'wp_enqueue_scripts', 'cwp_scripts' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment