watch-public-plugin.ts 329 B

123456789101112131415
  1. import type { PluginOption } from 'vite';
  2. import fg from 'fast-glob';
  3. export function watchPublicPlugin(): PluginOption {
  4. return {
  5. name: 'watch-public-plugin',
  6. async buildStart() {
  7. const files = await fg(['public/**/*']);
  8. for (const file of files) {
  9. this.addWatchFile(file);
  10. }
  11. },
  12. };
  13. }