{"id":22923,"library":"vite-plugin-watch-and-run","title":"Vite Plugin Watch and Run","description":"A Vite plugin (v1.8.0) that watches specified files and runs a package.json script when changes are detected. Built on top of chokidar, it supports glob patterns, debouncing, and console output customization. Part of the KitQL ecosystem, it is actively maintained with regular releases. Unlike using chokidar directly, it integrates seamlessly into the Vite dev server lifecycle.","status":"active","version":"1.8.0","language":"javascript","source_language":"en","source_url":"https://github.com/jycouet/kitql","tags":["javascript","vite","vite-plugin","typescript"],"install":[{"cmd":"npm install vite-plugin-watch-and-run","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-watch-and-run","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-watch-and-run","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for plugin functionality","package":"vite","optional":false}],"imports":[{"note":"Default export; named import `WatchAndRun` also works but default is recommended.","wrong":"const { watchAndRun } = require('vite-plugin-watch-and-run')","symbol":"default","correct":"import watchAndRun from 'vite-plugin-watch-and-run'"},{"note":"Named export available since v1.7.0.","wrong":"import WatchAndRun from 'vite-plugin-watch-and-run'","symbol":"WatchAndRun","correct":"import { WatchAndRun } from 'vite-plugin-watch-and-run'"},{"note":"TypeScript type export for configuration.","wrong":"","symbol":"Params (type)","correct":"import type { Params } from 'vite-plugin-watch-and-run'"}],"quickstart":{"code":"// vite.config.js\nimport { defineConfig } from 'vite';\nimport watchAndRun from 'vite-plugin-watch-and-run';\n\nexport default defineConfig({\n  plugins: [\n    watchAndRun([\n      {\n        watch: 'src/**/*.css',\n        run: 'npm run build:css',\n      },\n    ]),\n  ],\n});","lang":"javascript","description":"Watches CSS files for changes and runs the build:css script."},"warnings":[{"fix":"Review glob patterns. Any glob that relied on micromatch-specific features may need adjustment.","message":"Glob pattern handling changed: v1.8.0 uses picomatch instead of micromatch and extracts base paths for chokidar.","severity":"breaking","affected_versions":">=1.8.0"},{"fix":"Set `delay` to a value high enough to coalesce rapid changes (e.g., 500).","message":"The `delay` option (ms) is applied per run; multiple changes within the delay may coalesce but not guaranteed.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Remove this option from your configuration; it is no longer supported.","message":"Option `log_on_throw_is_not_a_new_class` was removed in vite-plugin-watch-and-run@1.8.0.","severity":"deprecated","affected_versions":">=1.8.0"},{"fix":"Verify the script exists in your package.json under `scripts`.","message":"The plugin runs the script in the project root; ensure the script is defined in package.json scripts.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `import watchAndRun from 'vite-plugin-watch-and-run'` instead.","cause":"Using `import { watchAndRun }` when the default export is needed.","error":"Error: The plugin `vite-plugin-watch-and-run` does not provide a default export"},{"fix":"Run `npm install vite-plugin-watch-and-run --save-dev` and ensure Vite is installed.","cause":"Missing dependency or incorrect installation.","error":"Module not found: Can't resolve 'vite-plugin-watch-and-run'"},{"fix":"Use default import: `import watchAndRun from 'vite-plugin-watch-and-run'`.","cause":"Importing the named export incorrectly.","error":"TypeError: watchAndRun is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}