A plugin for using Vite with Kirby.
When Vite runs in development mode, a new file called .dev
is created, containing Vite's dev server URL.
VITE_SERVER=http://localhost:5173
kirby-vite, a php plugin for Kirby, can use this file as an indicator to switch into development mode and load scripts and assets from Vite's dev server. When Vite runs in production mode, the .dev
file is removed.
The generation of a manifest.json
is enabled automatically.
In order to get static assets to work with kirby-vite, this plugin sets Vite's server origin.
vite-plugin-live-reload is used to watch the following paths:
site/(templates|snippets|controllers|models|layouts)/**/*.php
content/**/*
You can disable this behavior or define your own paths:
// vite.config.js
import kirby from 'vite-plugin-kirby'
export default {
// ...
plugins: [kirby({ watch: false })]
// or
plugins: [
// Note: paths are relative to Vite's root folder.
kirby({ watch: ['../site/templates/**/*.php'] })
]
}