https://github.com/arnoson/vite-plugin-live-reload
A simple live reloading plugin for vite.
https://github.com/arnoson/vite-plugin-live-reload
Last synced: about 1 month ago
JSON representation
A simple live reloading plugin for vite.
- Host: GitHub
- URL: https://github.com/arnoson/vite-plugin-live-reload
- Owner: arnoson
- Created: 2020-12-13T20:41:31.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-11-28T14:02:57.000Z (over 1 year ago)
- Last Synced: 2024-09-19T07:48:48.466Z (7 months ago)
- Language: TypeScript
- Homepage:
- Size: 197 KB
- Stars: 83
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- fucking-awesome-vite - vite-plugin-live-reload - Live reloading. (Plugins / Framework-agnostic Plugins)
- awesome-vite - vite-plugin-live-reload - Live reloading. (Plugins / Framework-agnostic Plugins)
README
# vite-plugin-live-reload
A simple live reloading plugin for [vite](https://github.com/vitejs/vite).## Example
I use this configuration when working with [Kirby CMS](https://getkirby.com/), but it works great with any backend!Note: 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'),
]
}
```## Usage
Watch one or more paths:
```js
liveReload('my/path/**/*.php')
``````js
liveReload(['my/path/**/*.php', 'my/other/path/**/*.php'])
```The plugin uses a [chokidar](https://github.com/paulmillr/chokidar) watcher. See the chokidar documentation to find out which path notations are supported.
## Options
### Root
By default Vite's root directory is used, but you can specify your own directory:
```js
liveReload('my-file', { root: process.cwd() })
```### Always reload
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 })
```