User-7611483 posted
My project is the default ASP.NET Core + Angular project that you can find in Visual Studio, but with different modules of course. But the large part is still the same. I've noticed that on publishing to Azure, when I look in the console I still see errors
saying it can't connect to `/dist/__webpack_hmr` and that I should enable angular prod mode. After checking `boot.browser.ts` I noticed this is because module.hot is not undefined.
if (module.hot) {
module.hot.accept();
module.hot.dispose(() => {
// Before restarting the app, we create a new root element and dispose the old one
const oldRootElem = document.querySelector("app");
const newRootElem = document.createElement("app");
oldRootElem!.parentNode!.insertBefore(newRootElem, oldRootElem);
modulePromise.then(appModule => appModule.destroy());
});
} else {
enableProdMode();
}
I modified my startup.cs to this:
if (env.EnvironmentName == EnvironmentName.Development)
{
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
{
HotModuleReplacement = true
});
app.UseDeveloperExceptionPage();
}
else
{
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
{
HotModuleReplacement = false
});
app.UseExceptionHandler("/Home/Error");
}
This seems to fix it locally, however when publishing module.hot is still not undefined, even though I do set HotModuleReplacement to false. I really don't understand how this doesn't work on Azure but does work locally