Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document how to add new globs to be watched #14423

Closed
1 of 4 tasks
bradwbradw opened this issue Sep 20, 2023 · 2 comments · Fixed by #14469
Closed
1 of 4 tasks

document how to add new globs to be watched #14423

bradwbradw opened this issue Sep 20, 2023 · 2 comments · Fixed by #14469
Labels
documentation Improvements or additions to documentation

Comments

@bradwbradw
Copy link

Documentation is

  • Missing
  • Outdated
  • Confusing
  • Not sure?

Explain in Detail

The documentation at https://vitejs.dev/config/server-options.html#server-watch is unclear about how to add a specific folder / file extension glob to be watched. In my case, i have a directory with svg files in it svg/*/*.svg. I would like vite to reload when I edit an SVG file but it does not. An example with this would be really useful.

The doc is clear on how to use server.watch to set options for chokidar, but it's unclear how to specify the paths, as per chokidar.watch(paths, [options])

Your Suggestion for Changes

Add an example on how to set up additional folders or file extensions to be watched for changes and cause a reload, using globs.

Reproduction

No response

Steps to reproduce

No response

@bradwbradw bradwbradw added the documentation Improvements or additions to documentation label Sep 20, 2023
@bluwy
Copy link
Member

bluwy commented Sep 21, 2023

The watch option is not used to configure files that are watched and reload the browser. Vite will watch them, but reloads only happen if they invalidate the page, e.g. they're imported and Vite is able to see and tell the browser to apply HMR. If you want to always reload regardless of that, you should use https://github.com/antfu/vite-plugin-restart with the reload option (looks like it's not documented in the readme, but it exists in source code). Maybe the docs can explain and point to this plugin.

@bradwbradw
Copy link
Author

thanks @bluwy that helps

@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants