https://github.com/lostpebble/vite-plugin-watch-node-modules
A plugin to force Vite to watch for changes in selected packages inside the node_modules folder
https://github.com/lostpebble/vite-plugin-watch-node-modules
Last synced: 10 months ago
JSON representation
A plugin to force Vite to watch for changes in selected packages inside the node_modules folder
- Host: GitHub
- URL: https://github.com/lostpebble/vite-plugin-watch-node-modules
- Owner: lostpebble
- Created: 2025-05-08T18:42:26.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-09T14:48:44.000Z (about 1 year ago)
- Last Synced: 2025-07-30T05:17:34.703Z (10 months ago)
- Language: TypeScript
- Size: 19.5 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# vite-plugin-watch-node-modules
On NPM: https://www.npmjs.com/package/vite-plugin-watch-node-modules
A plugin to watch selected packages inside `node_modules` folders in your repo for changes, and trigger a reload in Vite.
# Features
* Hot-reload any file changes to packages inside any `node_modules` in your repo that match your provided `modules[]` array.
## Getting Started
Install the plugin:
```
bun i -d vite-plugin-watch-node-modules
```
Then add the plugin to your Vite config:
```ts
import { watchNodeModules } from "vite-plugin-watch-node-modules";
// https://vite.dev/config/
export default defineConfig({
plugins: [
// ...
watchNodeModules(["@my-module/great", "my-dev-module"], {
cwd: path.join(process.cwd(), "../../../"),
}),
],
});
```
In this example, we are watching for changes to modules matching `@my-module/great` and `my-dev-module`- but our actual Vite project is
3 folders deep in the monorepo, so we add the `cwd` option to get make sure we search for any matching modules from the root of the repo.
## Options
The options interface is:
```
interface IWatchNodeModulesOptions {
cwd?: string;
}
```
You can set a different `cwd` if you want to watch a different directory than the current working directory.
This is useful if you are using a monorepo setup and want to watch packages in the root of the monorepo.