Giter Club home page Giter Club logo

wp-vite-theme's Introduction

WordPress Vite Theme

Proof of Concept (PoC) WordPress theme integrate with ViteJS. Motivated from wp-theme-vite-tailwind.

Requirements

  • PHP version >= 8.2
  • NodeJS version >= 18

Brief Setup for Development Mode

  • You have WordPress project that run with wp server or any other development tools like Laragon or Valet. It will shows URL like http://localhost:8080 if you use wp server or your-wp-project.test if you use Laragon or Valet.
  • Go to wp-content/themes directory. Then download wp-vite-theme project with command below.
composer create-project kresnasatya/wp-vite-theme <your-theme-name> && cd <your-theme-name>
  • Run composer install.
  • Run pnpm install or npm install.
  • Run pnpm run dev or npm run dev.
  • Change VITE_SERVER value in.env file with the Vite URL.

If you open the Vite URL it will contain empty file because it serves as a runner for your assets such as CSS and JavaScript.

Try to edit index.php or any file with .php extension then save it! Vite will trigger full-reload event so browser reload the page automatically. Thanks to handleHotUpdate hook from Vite.

Cheatsheet.

How to handling static assets in CSS and JS in WordPress + Vite Environment?

In production mode, static assets like images, fonts work well BUT not in development mode!

In order to make it works, you need to set a symbolic link or symlink from source folder to destination folder. Here's the example.

# I store my images file in public directory on wp-vite-theme.
# I make a WordPress project called wpground.
# I make a WordPress theme called wp-vite-theme.
# The ~ is a tilde symbol mean a "home" symbol in macOS.

# Images
ln -s ~/wpground/wp-content/wp-vite-theme/public/images ~/wpground/images

# Fonts
ln -s ~/wpground/wp-content/wp-vite-theme/public/fonts ~/wpground/fonts

Brief Setup for Production Mode

  • Stop wp server and pnpm run dev or npm run dev.
  • Change the value of VITE_ENV in .env file from development to production.
  • Run command pnpm run build or npm run build.
  • Run wp server again.

Credits

wp-vite-theme's People

Contributors

kresnasatya avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

yixuqiu

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.