@@ -94,15 +94,37 @@ export async function watchContents(nuxt: Nuxt, options: ModuleOptions, manifest
94
94
95
95
const sourceMap = collections . flatMap ( ( c ) => {
96
96
if ( c . source ) {
97
- return c . source . filter ( s => ! s . repository ) . map ( s => ( { collection : c , source : s , cwd : s . cwd && withTrailingSlash ( s . cwd ) } ) )
97
+ return c . source . filter ( s => ! s . repository ) . map ( ( s ) => {
98
+ const { fixed } = parseSourceBase ( s )
99
+ return { collection : c , source : s , cwd : s . cwd && withTrailingSlash ( s . cwd ) , prefix : s . cwd && withTrailingSlash ( join ( s . cwd , fixed ) ) }
100
+ } )
98
101
}
99
102
return [ ]
100
- } )
103
+ } ) . filter ( ( { source } ) => source . cwd )
104
+
101
105
const dirsToWatch = Array . from ( new Set ( sourceMap . map ( ( { source } ) => source . cwd ) ) )
102
106
// Filter out empty cwd for custom collections
103
107
. filter ( Boolean )
104
108
105
- const watcher = chokidar . watch ( dirsToWatch , { ignoreInitial : true } )
109
+ const watcher = chokidar . watch ( dirsToWatch , {
110
+ ignoreInitial : true ,
111
+ ignored : ( path ) => {
112
+ const match = sourceMap . find ( ( { source, cwd, prefix } ) => {
113
+ if ( path + '/' === prefix ) return true
114
+ if ( prefix && path . startsWith ( prefix ) ) {
115
+ return micromatch . isMatch (
116
+ path . substring ( cwd . length ) ,
117
+ source . include ,
118
+ { ignore : source ! . exclude || [ ] , dot : true } ,
119
+ )
120
+ }
121
+
122
+ return false
123
+ } )
124
+
125
+ return ! match
126
+ } ,
127
+ } )
106
128
107
129
watcher . on ( 'add' , onChange )
108
130
watcher . on ( 'change' , onChange )
0 commit comments