@@ -124,7 +124,7 @@ function attachWebpackDevMiddleware(app: any, webpackConfig: webpack.Configurati
124
124
125
125
function copyRecursiveSync ( from : typeof fs , to : typeof fs , rootDir : string , exclude : RegExp [ ] ) {
126
126
from . readdirSync ( rootDir ) . forEach ( filename => {
127
- const fullPath = path . join ( rootDir , filename ) ;
127
+ const fullPath = pathJoinSafe ( rootDir , filename ) ;
128
128
const shouldExclude = exclude . filter ( re => re . test ( fullPath ) ) . length > 0 ;
129
129
if ( ! shouldExclude ) {
130
130
const fileStat = from . statSync ( fullPath ) ;
@@ -138,6 +138,17 @@ function copyRecursiveSync(from: typeof fs, to: typeof fs, rootDir: string, excl
138
138
} ) ;
139
139
}
140
140
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
+
141
152
function beginWebpackWatcher ( webpackConfig : webpack . Configuration ) {
142
153
const compiler = webpack ( webpackConfig ) ;
143
154
compiler . watch ( { /* watchOptions */ } , ( err , stats ) => {
0 commit comments