The Guild LogoThe Guild Monogram
Docs

KitQL Docs

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

Documentation

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

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

In your svelte.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' /** @type {import('@sveltejs/kit').Config} */ const config = { kit: { vite: { plugins: [ watchAndRun([ { watch: '**/*.(gql|graphql)', run: 'npm run gen' // to trigger the script "gen" of your package.json // delay: 500, Optional parameter to delay the run command. } ]) ] } } } export default config

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 I recommend to use npm run xxx as it will work for npm yarn and pnpm 🙃