@@ -93,7 +93,6 @@ function attachWebpackDevMiddleware(app: any, webpackConfig: webpack.Configurati
9393
9494// Attach Webpack dev middleware and optional 'hot' middleware
9595const compiler = webpack ( webpackConfig ) ;
96- const originalFileSystem = compiler . outputFileSystem ;
9796app . use ( require ( 'webpack-dev-middleware' ) ( compiler , {
9897noInfo : true ,
9998publicPath : webpackConfig . output . publicPath
@@ -108,7 +107,7 @@ function attachWebpackDevMiddleware(app: any, webpackConfig: webpack.Configurati
108107// file on disk wouldn't match the file served to the browser, and the source map line numbers wouldn't
109108// match up. Breakpoints would either not be hit, or would hit the wrong lines.
110109( 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 ) $ / ] ) ;
112111} ) ;
113112
114113if ( enableHotModuleReplacement ) {
@@ -122,17 +121,20 @@ function attachWebpackDevMiddleware(app: any, webpackConfig: webpack.Configurati
122121}
123122}
124123
125- function copyRecursiveSync ( from : typeof fs , to : typeof fs , rootDir : string , exclude : RegExp [ ] ) {
124+ function copyRecursiveToRealFsSync ( from : typeof fs , rootDir : string , exclude : RegExp [ ] ) {
126125from . readdirSync ( rootDir ) . forEach ( filename => {
127126const fullPath = pathJoinSafe ( rootDir , filename ) ;
128127const shouldExclude = exclude . filter ( re => re . test ( fullPath ) ) . length > 0 ;
129128if ( ! shouldExclude ) {
130129const fileStat = from . statSync ( fullPath ) ;
131130if ( fileStat . isFile ( ) ) {
132131const fileBuf = from . readFileSync ( fullPath ) ;
133- to . writeFile ( fullPath , fileBuf ) ;
132+ fs . writeFileSync ( fullPath , fileBuf ) ;
134133} 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 ) ;
136138}
137139}
138140} ) ;
0 commit comments