From e59e2e0328eb1dc09230c5d0de976d8eb413bb33 Mon Sep 17 00:00:00 2001 From: SteveSandersonMS Date: Tue, 2 Feb 2016 15:34:34 +0000 Subject: [PATCH] Only use Webpack Dev Middleware in dev mode --- samples/react/ReactGrid/Startup.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/samples/react/ReactGrid/Startup.cs b/samples/react/ReactGrid/Startup.cs index 1aa8595..eb55c5a 100755 --- a/samples/react/ReactGrid/Startup.cs +++ b/samples/react/ReactGrid/Startup.cs @@ -53,10 +53,14 @@ namespace ReactExample app.UseExceptionHandler("/Home/Error"); } - app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { - HotModuleReplacement = true, - ReactHotModuleReplacement = true - }); + // In dev mode, the JS/TS/etc is compiled and served dynamically and supports hot replacement. + // In production, we assume you've used webpack to emit the prebuilt content to disk. + if (env.IsDevelopment()) { + app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { + HotModuleReplacement = true, + ReactHotModuleReplacement = true + }); + } // Add static files to the request pipeline. app.UseStaticFiles();