1
- import { copy , remove } from 'fs-extra'
2
1
import { watch } from 'chokidar'
2
+ import { copy , remove } from 'fs-extra'
3
3
import { normalizePath } from 'vite'
4
4
5
5
function toClientAndNode ( method , file ) {
@@ -18,14 +18,19 @@ function toDist(file) {
18
18
}
19
19
20
20
// copy shared files to the client and node directory whenever they change.
21
- watch ( 'src/shared/**/*.ts' )
21
+ watch ( 'src/shared' , {
22
+ ignored : ( path , stats ) => stats ?. isFile ( ) && ! path . endsWith ( '.ts' )
23
+ } )
22
24
. on ( 'change' , ( file ) => toClientAndNode ( 'copy' , file ) )
23
25
. on ( 'add' , ( file ) => toClientAndNode ( 'copy' , file ) )
24
26
. on ( 'unlink' , ( file ) => toClientAndNode ( 'remove' , file ) )
25
27
26
28
// copy non ts files, such as an html or css, to the dist directory whenever
27
29
// they change.
28
- watch ( 'src/client/**/!(*.ts|tsconfig.json)' )
30
+ watch ( 'src/client' , {
31
+ ignored : ( path , stats ) =>
32
+ stats ?. isFile ( ) && ( path . endsWith ( '.ts' ) || path . endsWith ( 'tsconfig.json' ) )
33
+ } )
29
34
. on ( 'change' , ( file ) => copy ( file , toDist ( file ) ) )
30
35
. on ( 'add' , ( file ) => copy ( file , toDist ( file ) ) )
31
36
. on ( 'unlink' , ( file ) => remove ( toDist ( file ) ) )
0 commit comments