{"id":22925,"library":"vite-plugin-watch","title":"vite-plugin-watch","description":"A Vite plugin that runs shell commands automatically when files matching a glob pattern change. Version 0.3.1 is the latest stable release, with infrequent updates. It supports single or multiple commands, configurable debounce timeout, silent mode, and optional initial run on Vite start. Differentiates from other watch plugins by integrating with the Vite dev server lifecycle and supporting minimal configuration.","status":"active","version":"0.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/lepikhinb/vite-plugin-watch","tags":["javascript","vite","typescript"],"install":[{"cmd":"npm install vite-plugin-watch","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-watch","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-watch","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Named export, not default.","wrong":"import watch from 'vite-plugin-watch'","symbol":"watch","correct":"import { watch } from 'vite-plugin-watch'"},{"note":"TypeScript type import.","wrong":"import { WatchPluginOptions } from 'vite-plugin-watch'","symbol":"WatchPluginOptions","correct":"import type { WatchPluginOptions } from 'vite-plugin-watch'"},{"note":"Use destructuring, not default assignment.","wrong":"const watch = require('vite-plugin-watch')","symbol":"watch (CommonJS)","correct":"const { watch } = require('vite-plugin-watch')"}],"quickstart":{"code":"// vite.config.js\nimport { defineConfig } from 'vite';\nimport { watch } from 'vite-plugin-watch';\n\nexport default defineConfig({\n  plugins: [\n    watch({\n      pattern: 'src/**/*.scss',\n      command: 'npm run build:css',\n      timeout: 1000,\n      silent: false,\n      onInit: true\n    })\n  ]\n});","lang":"typescript","description":"Configures vite-plugin-watch to run `npm run build:css` whenever any .scss file in src/ changes. Uses 1s debounce, shows output, runs on start."},"warnings":[{"fix":"For sequential commands, use array: `command: ['echo first', 'echo second']`.","message":"The `command` can be a string or an array of strings. If an array, each command runs sequentially.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"","message":"No deprecated features known.","severity":"deprecated","affected_versions":""},{"fix":"","message":"No known breaking changes between versions.","severity":"breaking","affected_versions":""}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `const { watch } = require('vite-plugin-watch')` or switch to ESM.","cause":"Using require() in a CommonJS file without proper destructuring or using ESM syntax in a CJS context.","error":"Unexpected token 'export'"},{"fix":"Run `npm i -D vite-plugin-watch` to install as dev dependency.","cause":"Package not installed or missing from package.json.","error":"Cannot find module 'vite-plugin-watch'"},{"fix":"Use `import { watch } from 'vite-plugin-watch'`.","cause":"Default import instead of named import.","error":"TypeError: watch is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}