@@ -12,6 +12,7 @@ import { withResolvers } from './utils.js';
12
12
13
13
const FILES_FOLDER_NAME = '_files' ;
14
14
const SOLUTION_FOLDER_NAME = '_solution' ;
15
+ const IGNORED_FILES = [ '**/.DS_Store' , '**/*.swp' ] ;
15
16
16
17
export class WebContainerFiles {
17
18
private _watcher : FSWatcher | undefined ;
@@ -20,11 +21,16 @@ export class WebContainerFiles {
20
21
const { contentDir, templatesDir } = this . _folders ( projectRoot ) ;
21
22
const cache = new FileMapCache ( logger , server , { contentDir, templatesDir } ) ;
22
23
23
- this . _watcher = watch ( [
24
- path . join ( contentDir , `**/${ FILES_FOLDER_NAME } /**/*` ) ,
25
- path . join ( contentDir , `**/${ SOLUTION_FOLDER_NAME } /**/*` ) ,
26
- templatesDir ,
27
- ] ) ;
24
+ this . _watcher = watch (
25
+ [
26
+ path . join ( contentDir , `**/${ FILES_FOLDER_NAME } /**/*` ) ,
27
+ path . join ( contentDir , `**/${ SOLUTION_FOLDER_NAME } /**/*` ) ,
28
+ templatesDir ,
29
+ ] ,
30
+ {
31
+ ignored : IGNORED_FILES ,
32
+ } ,
33
+ ) ;
28
34
29
35
this . _watcher . on ( 'all' , ( eventName , filePath ) => {
30
36
// new directories don't affect the file tree
@@ -63,7 +69,7 @@ export class WebContainerFiles {
63
69
`${ glob . convertPathToPattern ( contentDir ) } /**/${ SOLUTION_FOLDER_NAME } ` ,
64
70
`${ glob . convertPathToPattern ( templatesDir ) } /*` ,
65
71
] ,
66
- { onlyDirectories : true } ,
72
+ { onlyDirectories : true , ignore : IGNORED_FILES } ,
67
73
) ;
68
74
69
75
await Promise . all (
@@ -209,6 +215,7 @@ class FileMapCache {
209
215
async function createFileMap ( dir : string ) {
210
216
const filePaths = await glob ( `${ glob . convertPathToPattern ( dir ) } /**/*` , {
211
217
onlyFiles : true ,
218
+ ignore : IGNORED_FILES ,
212
219
} ) ;
213
220
214
221
// files are assumed to be sorted so that FileTree can skip some logic at runtime
0 commit comments