Registry / devops / vite-plugin-watch

vite-plugin-watch

JSON →
library0.3.1jsnpmunverified

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.

npm install vite-plugin-watch
INSTALL
IMPORT
SIG · VITE-PLUGIN-WATCH
V
vite-plugin-watch
devopsjavascriptv0.3.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

watch
import { watch } from 'vite-plugin-watch'
import watch from 'vite-plugin-watch'
Named export, not default.
WatchPluginOptions
import type { WatchPluginOptions } from 'vite-plugin-watch'
import { WatchPluginOptions } from 'vite-plugin-watch'
TypeScript type import.
watch (CommonJS)
const { watch } = require('vite-plugin-watch')
const watch = require('vite-plugin-watch')
Use destructuring, not default assignment.

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.

// vite.config.js import { defineConfig } from 'vite'; import { watch } from 'vite-plugin-watch'; export default defineConfig({ plugins: [ watch({ pattern: 'src/**/*.scss', command: 'npm run build:css', timeout: 1000, silent: false, onInit: true }) ] });
Debug
Known issues
gotchaThe `command` can be a string or an array of strings. If an array, each command runs sequentially.
fix
For sequential commands, use array: `command: ['echo first', 'echo second']`.
affects: >=0.0.0
deprecatedNo deprecated features known.
breakingNo known breaking changes between versions.
Errors
Common errors & fixes
Unexpected token 'export'
Using require() in a CommonJS file without proper destructuring or using ESM syntax in a CJS context.
fix
Use `const { watch } = require('vite-plugin-watch')` or switch to ESM.
Cannot find module 'vite-plugin-watch'
Package not installed or missing from package.json.
fix
Run `npm i -D vite-plugin-watch` to install as dev dependency.
TypeError: watch is not a function
Default import instead of named import.
fix
Use `import { watch } from 'vite-plugin-watch'`.
Upgrade
Version history
0.3.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
vite-plugin-watch — npm install vite-plugin-watch · libregistry