@@ -124,7 +124,7 @@ function attachWebpackDevMiddleware(app: any, webpackConfig: webpack.Configurati
124124
125125function copyRecursiveSync ( from : typeof fs , to : typeof fs , rootDir : string , exclude : RegExp [ ] ) {
126126 from . readdirSync ( rootDir ) . forEach ( filename => {
127- const fullPath = path . join ( rootDir , filename ) ;
127+ const fullPath = pathJoinSafe ( rootDir , filename ) ;
128128 const shouldExclude = exclude . filter ( re => re . test ( fullPath ) ) . length > 0 ;
129129 if ( ! shouldExclude ) {
130130 const fileStat = from . statSync ( fullPath ) ;
@@ -138,6 +138,17 @@ function copyRecursiveSync(from: typeof fs, to: typeof fs, rootDir: string, excl
138138 } ) ;
139139}
140140
141+ function pathJoinSafe ( rootPath : string , filePath : string ) {
142+ // On Windows, MemoryFileSystem's readdirSync output produces directory entries like 'C:'
143+ // which then trigger errors if you call statSync for them. Avoid this by detecting drive
144+ // names at the root, and adding a backslash (so 'C:' becomes 'C:\', which works).
145+ if ( rootPath === '/' && path . sep === '\\' && filePath . match ( / ^ [ a - z 0 - 9 ] + \: $ / i) ) {
146+ return filePath + '\\' ;
147+ } else {
148+ return path . join ( rootPath , filePath ) ;
149+ }
150+ }
151+
141152function beginWebpackWatcher ( webpackConfig : webpack . Configuration ) {
142153 const compiler = webpack ( webpackConfig ) ;
143154 compiler . watch ( { /* watchOptions */ } , ( err , stats ) => {
0 commit comments