Skip to content

Commit c42cfea

Browse files
committed
feat: attempts to track files by adding to FSWatcher
doesn't seem to be fully functional, but gets closer
1 parent 88dece2 commit c42cfea

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

app-config-vite/src/index.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
11
import rollupPlugin, { Options } from '@app-config/rollup';
2-
import type { Plugin } from 'vite';
2+
import type { Plugin, FSWatcher } from 'vite';
33

44
export * from '@app-config/rollup';
55

66
export default function appConfigVite(options: Options = {}): Plugin {
77
const plugin = rollupPlugin(options);
88

9+
let watcher: FSWatcher | undefined;
10+
911
return {
1012
...plugin,
1113
name: '@app-config/vite',
1214

15+
configureServer(server) {
16+
watcher = server.watcher;
17+
},
18+
19+
async load(id) {
20+
const result = await plugin.load!.call(this, id);
21+
22+
watcher?.add(plugin.currentFilePaths ?? []);
23+
24+
return result;
25+
},
26+
1327
async handleHotUpdate({ server, file }) {
1428
if (plugin.currentFilePaths?.includes(file)) {
15-
server.ws.send({
16-
type: 'full-reload',
17-
path: '@app-config/main',
18-
});
29+
server.ws.send({ type: 'full-reload' });
1930

2031
return [];
2132
}

0 commit comments

Comments
 (0)