WebpackDevMiddleware in ASP.NET Core app in Azure Service Fabric

I am trying to use WebpackDevMiddleware with HotModuleReplacement in an ASP.NET Core application. I followed the following guide: https://docs.microsoft.com/en-us/aspnet/core/client-side/spa-services in setting up webpack to work with ASP.NET.

When I deploy my ASP.NET Core application through Service Fabric, the following error occurs:

Error calling Node module with error: Webpack dev middleware could not be executed due to error loading "aspnet-webpack" ....

I noticed that inside my wwwroot/ folder I don't have node_modules , dependencies, etc .... and so this error makes sense. The ASP.NET application core does not seem to have access to the aspnet-webpack Node module. In addition, a visible dependencies folder appears in the folders of other wwwroot projects, visible in Visual Studio, while I don't have such a folder.

I am wondering how can I give the main ASP.NET application access to the modules it needs?

+5
source share
1 answer

It seems that ServiceFabric does not currently support Hot Module replacement.

To get around this, I added the following:

 #if DEBUG app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true }); #endif 

So, you use HMR only in debug mode and when publishing in a local / production cluster, HMR is not used.

+2
source

Source: https://habr.com/ru/post/1271769/


All Articles