Docs
Setup
Vite Plugin - Watch-and-Run

⚡How to - vite-plugin-watch-and-run

Installation

If you have @kitql/all-in you don't need to install this manually.

If you want to install it stand alone, please do

Terminal
yarn add -D vite-plugin-watch-and-run

Configuration

Add watchAndRun plugin with the following configuration:

  • watch: a glob pattern to watch for changes. This will be matched against the absolute path for altered files.
  • run: a command to trigger when a file change is detected (You can be very creative 🥳!)
vite.config.js
import path from 'path'
import watchAndRun from 'vite-plugin-watch-and-run'
 
/** @type {import('vite').UserConfig} */
const config = {
  plugins: [
    watchAndRun([
      {
        name: 'gen',
        watchKind: ['add', 'change', 'unlink'],
        watch: path.resolve('src/**/*.(gql|svelte)'),
        run: 'npm run gen',
        delay: 300
      }
    ])
  ]
}
 
export default config

Side Notes

Go back to Get Started.