Giter Site home page Giter Site logo

hasanuzzamanbe / wp-boilerplate-vue-with-vite Goto Github PK

View Code? Open in Web Editor NEW
72.0 6.0 22.0 410 KB

This is a WordPress boilerplate plugin using vue 3, build with vite. Also tailwind setup available.

Home Page: https://wpminers.com/make-wordpress-plugin-using-vue-with-vite-build/

CSS 0.19% PHP 43.98% JavaScript 50.57% Vue 4.86% SCSS 0.19% Hack 0.21%
vue-vite wordpress-development wordpress-plugin wordpress-plugin-boilerplate wordpress-plugin-development wp-plugin-vue-vite

wp-boilerplate-vue-with-vite's Introduction

WP Plugin Vue Boilerplate (Vite Build)

Run only 4 commands and make your own plugin

  • git clone https://github.com/hasanuzzamanbe/wp-boilerplate-vue-with-vite.git
  • cd wp-boilerplate-vue-with-vite
  • npm i
  • node aladin and enter your Plugin Name in the command prompt.

Aladdin ๐Ÿงžโ€โ™‚๏ธ will make it within a blink.

Congratulations Everything is done ๐Ÿฅณ npm run dev to run development mode. Find and activate your plugin in WordPress.


This is a Customizable Boilerplate WordPress Plugin that is developed as a single-page app with Vue js and Vite. You don't have to reload the page all the time. Read the Detailed quick setup can help to make a new fresh plugin within 10 sec

How faster is Vite than the Webpack in development?

It needs milliseconds to update the dom, Check very short video

photo_2023-10-09 00 03 48

How to use? (details)

  • Just clone/fork this repository on your wp-content/plugins directory
  • run: npm i You may check the package.json file for more info.

Make Your Own plugin from boilerplate within 10 sec (Quick Setup ๐Ÿงžโ€โ™‚๏ธ)

No worries! It needs just one command to create your own plugin with your Namespaces, Text Domains and Slugs.

Open the directory in the terminal (cd wp-boilerplate-vue-with-vite)

Call aladin ๐Ÿงžโ€โ™‚๏ธ by one command.

  • run: node aladin and enter your Plugin Name in the command prompt.

Aladdin ๐Ÿงžโ€โ™‚๏ธ will make it within a blink. Congratulations Everything is done ๐Ÿฅณ

Just find the plugin name and activate it in your WordPress. Run development mode by npm run dev

Yes, you can update all those things later also.

Manual setup(Not recommended):

you have to replace all the NameSpaces and slugs. You may search and replace in plugin directory. by these keywords bellow.

PluginClassName to yourClassName

pluginlowercase to yourpluginslug,

PLUGIN_CONST to YOUR_PLUGIN_SLUG,

PluginName to Your Plugin Name,

pluginslug to your-plugin-slug

production mode

You only need to run npm run production delete all excepts these files/directory.

  • assets
  • includes
  • plugin-entry.php (plugin Entry file)

Development Helping Docs:

Enqueue Assets:

Now easy enqueue from version 1.0.6 No need to worry about the dev environment enqueue or Production level enqueue. everything here can be managed 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

Example use case:

No need to enqueue production manually again, It will enqueue from manifest on production. Just call `Vite::enqueueScript()`

Vite::enqueueScript('my-plugin-script-boot', 'admin/start.js', array('jquery'), PLUGIN_CONST_VERSION, true)

Vite::enqueueStyle('my-plugin-style', 'scss/my-style.js', array(), PLUGIN_CONST_VERSION, true)

NOT RECOMMENDED wp_enqueue_script (see why)

If you want to use wp_enqueue_script then you have to call both dev and production manually:

(Production and dev enqueue script should be like this)

if (defined('PLUGIN_CONST_DEVELOPMENT') && PLUGIN_CONST_DEVELOPMENT !== 'yes') {
    wp_enqueue_script('pluginlowercase-script-boot', PLUGIN_CONST_URL . 'assets/js/start.js', array('jquery'), PLUGIN_CONST_VERSION, false);
} else {
    wp_enqueue_script('pluginlowercase-script-boot', 'http://localhost:8880/' . 'src/admin/start.js', array('jquery'), PLUGIN_CONST_VERSION, true);
}

Read web documentation here Details Docs

If you face any issues feel free to let me know. :)


Vue + Element UI auto command boilerplate

You can check another boilerplate plugin with vue js and element UI, You can create your own project using a simple command line on that project within 2 minutes.

Check it here: https://github.com/hasanuzzamanbe/wp-boilerplate-plugin-with-vuejs

Other Setups You May Use

Active Example plugins:

Plugin using this boilerplate: https://wordpress.org/plugins/buy-me-coffee/
Github Repo: https://github.com/hasanuzzamanbe/buy-me-coffee

wp-boilerplate-vue-with-vite's People

Contributors

hasanuzzamanbe avatar nuhel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

wp-boilerplate-vue-with-vite's Issues

Empty page on npm run watch

Hello i just clone your repo !

I do npm install and npm run watch but http://localhost:8880/ give me an empty page.

When i do npm run production and put the plugin in wordpress it's ok.

Don't know what i miss... really strange.

Thks !

Use shortCode on frontend

Hi, I used the registerShortCodes() function to register a new shortcode to be used for rendering a component on the frontend.
But how do I use it? Where are the scripts imported to render a vue component on the frontend?

public function registerShortCodes() : void {
    add_shortcode('test_shortcode', static fn () => '<div id="app"></div>');
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.