@@ -37,7 +37,8 @@ const { dir, output, replace } = argv
3737
3838if ( argv . map ) argv . map = { inline : false }
3939
40- let configFile
40+ // will be just one config file in the vast majority of cases
41+ const configFiles = new Set ( )
4142let argvConfigSet = false
4243
4344if ( argv . env ) process . env . NODE_ENV = argv . env
@@ -127,20 +128,23 @@ try {
127128 } ,
128129 } )
129130
130- if ( configFile ) watcher . add ( configFile )
131+ if ( configFiles . size ) watcher . add ( [ ... configFiles ] )
131132
132133 watcher . on ( 'ready' , printMessage ) . on ( 'change' , ( file ) => {
133134 let recompile = [ ]
134135
135- if ( input . includes ( file ) ) recompile . push ( file )
136+ // if it's a config file, skip to recompiling everything
137+ if ( ! configFiles . has ( file ) ) {
138+ if ( input . includes ( file ) ) recompile . push ( file )
136139
137- const dependants = depGraph
138- . dependantsOf ( file )
139- . concat ( getAncestorDirs ( file ) . flatMap ( depGraph . dependantsOf ) )
140+ const dependants = depGraph
141+ . dependantsOf ( file )
142+ . concat ( getAncestorDirs ( file ) . flatMap ( depGraph . dependantsOf ) )
140143
141- recompile = recompile . concat (
142- dependants . filter ( ( file ) => input . includes ( file ) ) ,
143- )
144+ recompile = recompile . concat (
145+ dependants . filter ( ( file ) => input . includes ( file ) ) ,
146+ )
147+ }
144148
145149 if ( ! recompile . length ) recompile = input
146150
@@ -168,7 +172,7 @@ function rc(ctx, path) {
168172 'Config Error: Can not set from or to options in config file, use CLI arguments instead' ,
169173 )
170174 }
171- configFile = rc . file
175+ configFiles . add ( rc . file )
172176 return rc
173177 } )
174178 . catch ( ( err ) => {
0 commit comments