# vite-plugin-watch

> Vite plugin to run custom commands on file changes

Latest version **0.3.1** (published 2024-03-18) · 0 weekly downloads

## Install

```sh
npm install vite-plugin-watch
pnpm add vite-plugin-watch
yarn add vite-plugin-watch
bun add vite-plugin-watch
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2024-03-18 |
| First published | 2022-12-14 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10.6.0 |
| Dependencies | 1 |
| Unpacked size | 33.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 43 |
| Author | Boris Lepikhin |
| Maintainers | lepikhinb |
| Keywords | vite |

## Links

- npm: https://www.npmjs.com/package/vite-plugin-watch
- Repository: https://github.com/lepikhinb/vite-plugin-watch
- Homepage: https://github.com/lepikhinb/vite-plugin-watch#readme
- Issues: https://github.com/lepikhinb/vite-plugin-watch/issues
- npm.io page: https://npm.io/package/vite-plugin-watch

## Dependencies (1)

- [minimatch](https://npm.io/package/minimatch.md) ^5.1.1

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.3.1 (latest) — 2024-03-18
- 0.3.0 — 2024-03-13
- 0.2.0 — 2023-06-21
- 0.1.1 — 2023-01-20
- 0.1.0 — 2022-12-14

## README

# Vite Watcher Runner

A Vite plugin that runs custom shell commands on file changes.

## Installation

You can install the package via `npm` or `yarn`:

```bash
npm i -D vite-plugin-watch
# or
yarn add -D vite-plugin-watch
```

## Usage

Import the package from `vite.config.js` and configure it.

```js
import { defineConfig } from "vite"
import { watch } from "vite-plugin-watch"

export default defineConfig({
  plugins: [ 
    watch({
      pattern: "app/{Data,Enums}/**/*.php",
      command: "php artisan typescript:transform",
    }),
  ],
})
```

Once a tracked file changes, the plugin will execute a specified command.

The paths of tracked files are configured as [glob patterns](<https://en.wikipedia.org/wiki/Glob_(programming)>):

- Use \* to match anything except slashes and hidden files
- Use \*\* to match zero or more directories
- Use comma separate values between {} to match against a list of options

## Plugin options

| name    | type             | description                                              | default |
| ------- | ---------------- | -------------------------------------------------------- | ------- |
| pattern | string\|string[] | Tracked files paths                                      |         |
| command | string\|string[] | One or multiple command(s) to be executed on file change |         |
| timeout | number           | Timeout between triggering the same command              | 500     |
| silent  | boolean          | Hide the output in the console                           | false   |
| onInit  | boolean          | Run the command on Vite start                            | true    |

## Advanced Inertia

[<img src="https://advanced-inertia.com/og.png" width="420px" />](https://advanced-inertia.com)

Take your Inertia.js skills to the next level with my book [Advanced Inertia](https://advanced-inertia.com/).
Learn advanced concepts and make apps with Laravel and Inertia.js a breeze to build and maintain.

## Momentum

Momentum is a set of packages designed to improve your experience building Inertia-powered apps.

- [Modal](https://github.com/lepikhinb/momentum-modal) — Build dynamic modal dialogs for Inertia apps
- [Preflight](https://github.com/lepikhinb/momentum-preflight) — Realtime backend-driven validation for Inertia apps
- [Paginator](https://github.com/lepikhinb/momentum-paginator) — Headless wrapper around Laravel Pagination
- [Trail](https://github.com/lepikhinb/momentum-trail) — Frontend package to use Laravel routes with Inertia
- [Lock](https://github.com/lepikhinb/momentum-lock) — Frontend package to use Laravel permissions with Inertia
- [Layout](https://github.com/lepikhinb/momentum-layout) — Persistent layouts for Vue 3 apps
- [Vite Plugin Watch](https://github.com/lepikhinb/vite-plugin-watch) — Vite plugin to run shell commands on file changes

## Credits

- [Boris Lepikhin](https://twitter.com/lepikhinb)
- [All Contributors](../../contributors)

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

---
_Source: https://npm.io/package/vite-plugin-watch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
