@@ -93,7 +93,6 @@ function attachWebpackDevMiddleware(app: any, webpackConfig: webpack.Configurati
93
93
94
94
// Attach Webpack dev middleware and optional 'hot' middleware
95
95
const compiler = webpack ( webpackConfig ) ;
96
- const originalFileSystem = compiler . outputFileSystem ;
97
96
app . use ( require ( 'webpack-dev-middleware' ) ( compiler , {
98
97
noInfo : true ,
99
98
publicPath : webpackConfig . output . publicPath
@@ -108,7 +107,7 @@ function attachWebpackDevMiddleware(app: any, webpackConfig: webpack.Configurati
108
107
// file on disk wouldn't match the file served to the browser, and the source map line numbers wouldn't
109
108
// match up. Breakpoints would either not be hit, or would hit the wrong lines.
110
109
( compiler as any ) . plugin ( 'done' , stats => {
111
- copyRecursiveSync ( compiler . outputFileSystem , originalFileSystem , '/' , [ / \. h o t - u p d a t e \. ( j s | j s o n ) $ / ] ) ;
110
+ copyRecursiveToRealFsSync ( compiler . outputFileSystem , '/' , [ / \. h o t - u p d a t e \. ( j s | j s o n ) $ / ] ) ;
112
111
} ) ;
113
112
114
113
if ( enableHotModuleReplacement ) {
@@ -122,17 +121,20 @@ function attachWebpackDevMiddleware(app: any, webpackConfig: webpack.Configurati
122
121
}
123
122
}
124
123
125
- function copyRecursiveSync ( from : typeof fs , to : typeof fs , rootDir : string , exclude : RegExp [ ] ) {
124
+ function copyRecursiveToRealFsSync ( from : typeof fs , rootDir : string , exclude : RegExp [ ] ) {
126
125
from . readdirSync ( rootDir ) . forEach ( filename => {
127
126
const fullPath = pathJoinSafe ( rootDir , filename ) ;
128
127
const shouldExclude = exclude . filter ( re => re . test ( fullPath ) ) . length > 0 ;
129
128
if ( ! shouldExclude ) {
130
129
const fileStat = from . statSync ( fullPath ) ;
131
130
if ( fileStat . isFile ( ) ) {
132
131
const fileBuf = from . readFileSync ( fullPath ) ;
133
- to . writeFile ( fullPath , fileBuf ) ;
132
+ fs . writeFileSync ( fullPath , fileBuf ) ;
134
133
} else if ( fileStat . isDirectory ( ) ) {
135
- copyRecursiveSync ( from , to , fullPath , exclude ) ;
134
+ if ( ! fs . existsSync ( fullPath ) ) {
135
+ fs . mkdirSync ( fullPath ) ;
136
+ }
137
+ copyRecursiveToRealFsSync ( from , fullPath , exclude ) ;
136
138
}
137
139
}
138
140
} ) ;
0 commit comments