The Guild LogoThe Guild Monogram

KitQL Docs

A set of tools, helping you building efficient apps in a fast way.


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


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

If you want to install it stand alone, please do

yarn add -D @kitql/vite-plugin-watch-and-run

Configuration In your vite.config.js add watchAndRun 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 🥳!)
import watchAndRun from '@kitql/vite-plugin-watch-and-run' import path from 'path'; /** @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;

List of watchKind#

Default list when not set: ['add', 'change', 'unlink']

Other possible events: "addDir", "all", "error", "raw", "ready", "unlinkDir".

More info here:

Side Notes#

  • delay is good in case you have 200 files added realy fast! Like this the cmd is executed only once.

  • For the run command we recommend to use npm run xxx as it will work for npm, yarn and pnpm 🙃

Go back to Get Started.