A simple live reloading plugin for vite.
npm install vite-plugin-live-reloadNote: by default the paths are relative to Vite's root folder.
``js
// vite.config.js
import liveReload from 'vite-plugin-live-reload'
export default {
// ...
plugins: [
liveReload('../site/(templates|snippets|controllers|models)/*/.php'),
]
}
`
Watch one or more paths:
`js`
liveReload('my/path/*/.php')
`js`
liveReload(['my/path//.php', 'my/other/path//.php'])
The plugin uses a chokidar watcher. See the chokidar documentation to find out which path notations are supported.
By default Vite's root directory is used, but you can specify your own directory:
`js`
liveReload('my-file', { root: process.cwd() })
If the modified file is an .html file, Vite's client only reloads the page if the browser is currently on this HTML page. With alwaysReload the browser is reloaded anyway.
`js``
liveReload('my-file', { alwaysReload: true })