This is a Customizable sample WordPress Plugin which is developed as a single page app on backend with Vue js and Tailwind custom build css. and you don't have to reload page all the time.
Caption: Dummy dashboard with custom build vue + tailwind setup (Vite realtime environment)
- Just clone/fork this repository
- Check the package.json file
- command:
npm i
- command:
npm run watch
for development and for production:npm run production
On production you only need
- assets
- includes
- wp-plugin-with-vue-tailwind.php (plugin Entry file)
No need to worry about the dev environment enqueue or Production level enqueue.
everything here can manage by Vite dedicated class (includes/Classes/Vite.php
)
Just Call like this
Vite::enqueueScript($enqueueTag, $yourAdminSourcePath, $dependency = [], $version = null, $inFooter = false)
Note: same as wp_enqueue_script
No need to enqueue production manually again, It will enqueue from manifest on production. Just call `Vite::enqueueScript()`
If you want to use wp_enqueue_script
then you have to call both dev and production manually:
(Production and dev enqueue script should like this)
if (defined('WPM_DEVELOPMENT') && WPM_DEVELOPMENT !== 'yes') {
wp_enqueue_script('WPWVT-script-boot', WPM_URL . 'assets/js/start.js', array('jquery'), WPM_VERSION, false);
} else {
wp_enqueue_script('WPWVT-script-boot', 'http://localhost:8880/' . 'src/admin/start.js', array('jquery'), WPM_VERSION, true);
}
If you face any issue feel free to let me know. :)
You can check another boilerplate plugin with vue js and element UI, You can create your own project using simple command line on that project within 2 mint.
Check it here: https://github.com/hasanuzzamanbe/wp-boilerplate-plugin-with-vuejs
- WordPress Plugin with Vue 3, tailwind (Laravel Mix Build) [https://github.com/hasanuzzamanbe/wp-plugin-with-vue-tailwind]
- WordPress Plugin with Vue 2, Element UI (Laravel Mix Build) [https://github.com/hasanuzzamanbe/wp-boilerplate-plugin-with-vuejs]