Skip to content

oguilleux/vite-wordpress-starter-theme

Repository files navigation

WordPress Vite.js starter theme

Under the hood

Requirements

Usage

First, clone this repository in your WordPress themes directory.

Then, run the following commands in the theme's directory :

npm install

Launch your watch for assets with :

npm run dev

For production sites, create your build with :

npm run build

Vite & WordPress

  • All the static assets used in scss or js files (images, fonts, etc.) are copied as-is to the dist directory. The other images used directly in php files are not copied.
  • To detect dev mode in php there is no dist directory, it is added on build.

Troubleshooting [dev mode]

  • Vite needs to know the root path of your project so you cannot use a subdirectory as the root of your WordPress installation.
  • If you haven't started the dev server, your assets will not be compiled just npm run dev and refresh page.
  • In your scss files use the alias @ to target the static/ directory. ie : background-image: url('@/img/logo.png');