From 62aac5852932b5e67b7d8e1db478344aaad054a0 Mon Sep 17 00:00:00 2001
From: Pavlo Glazkov
Date: Sat, 8 Apr 2017 13:34:19 +0200
Subject: [PATCH] Fix watchOptions in webpack.config.js being ignored by
WebpackDevMiddleware (#806)
This enables Docker HMR workflow and the workaround mentioned in this comment: https://github.com/aspnet/JavaScriptServices/issues/806#issuecomment-290081291
---
.../npm/aspnet-webpack/src/WebpackDevMiddleware.ts | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/WebpackDevMiddleware.ts b/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/WebpackDevMiddleware.ts
index 154ccacd..bf31d822 100644
--- a/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/WebpackDevMiddleware.ts
+++ b/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/WebpackDevMiddleware.ts
@@ -108,7 +108,8 @@ function attachWebpackDevMiddleware(app: any, webpackConfig: webpack.Configurati
const compiler = webpack(webpackConfig);
app.use(require('webpack-dev-middleware')(compiler, {
noInfo: true,
- publicPath: webpackConfig.output.publicPath
+ publicPath: webpackConfig.output.publicPath,
+ watchOptions: webpackConfig.watchOptions
}));
// After each compilation completes, copy the in-memory filesystem to disk.
@@ -207,7 +208,7 @@ function pathJoinSafe(rootPath: string, filePath: string) {
function beginWebpackWatcher(webpackConfig: webpack.Configuration) {
const compiler = webpack(webpackConfig);
- compiler.watch({ /* watchOptions */ }, (err, stats) => {
+ compiler.watch(webpackConfig.watchOptions || {}, (err, stats) => {
// The default error reporter is fine for now, but could be customized here in the future if desired
});
}