File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change 1
1
import rollupPlugin , { Options } from '@app-config/rollup' ;
2
- import type { Plugin } from 'vite' ;
2
+ import type { Plugin , FSWatcher } from 'vite' ;
3
3
4
4
export * from '@app-config/rollup' ;
5
5
6
6
export default function appConfigVite ( options : Options = { } ) : Plugin {
7
7
const plugin = rollupPlugin ( options ) ;
8
8
9
+ let watcher : FSWatcher | undefined ;
10
+
9
11
return {
10
12
...plugin ,
11
13
name : '@app-config/vite' ,
12
14
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
+
13
27
async handleHotUpdate ( { server, file } ) {
14
28
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' } ) ;
19
30
20
31
return [ ] ;
21
32
}
You can’t perform that action at this time.
0 commit comments