antfu / vite-plugin-restart

Custom files/globs to restart Vite server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Look for new file and file deletion

NicolaSpadari opened this issue · comments

I run this plugin in vite + vue 3, with vite-plugin-pages.
I need to watch for changes under the src/pages folder, when a file is created or deleted the server needs to restart, since the other plugins throws an error if i navigate to the page and the server wasn't restarted.

Can't seem to observe the files in a folder with this plugin.
No support or I just don't undestand how?

Yeah, we only listen to change at this moment

PR welcome, thanks!

ohh~~ this is what I need also, and I am now working on it... but it seems that I have met a problem:
how can I control the whole vite server to restart ? ( instead of just the vite websocket server, because I know there is a way to restart the vite websocket server, using ViteDevServer.close() or ViteDevServer.listen(), but if do so, only the websocket server will restart, not the whole vite server )
the reason why I try to restart the whole vite server is that I want to reload the Vite Plugins.... lol

For some reason I'm not being able to filter files in a folder using glob patterns, so I ended up doing some "manual" controls just passing the name of the folder under /src
Anyway, this is my small custom plugin for restarting the server when a file under the /pages folder changes: link

For some reason I'm not being able to filter files in a folder using glob patterns, so I ended up doing some "manual" controls just passing the name of the folder under /src
Anyway, this is my small custom plugin for restarting the server when a file under the /pages folder changes: link

bro, thanks for your plugin though, but as the code shows, you are using server.ws.send({ type: "full-reload" }) , which it can only reload the pages instead of reload the vite entity..... so I think this might not be a true reload ?

I don't think so, since the plugin touches the vite.config file, which is the file that causes the instance to update.
When I create a page for example, this pops up in the terminal
server-restart

I don't think so, since the plugin touches the vite.config file, which is the file that causes the instance to update.
When I create a page for example, this pops up in the terminal
server-restart

thanks a million bro, I just miss the touch(), and now works on my side !! thanks !