I am building a nuget package which will have a static frontend when packaged and distributed (working currently)
and during development it serves from the spa proxy of a dev server (working as well)
however, I am struggling to find a clean and concise way of differentiating between the packaged version of the application and the local version
I would like to know what the best way to achieve this is
in short, “How do I differentiate between production builds of a Nuget package and local builds”
something like below (but don’t feel pressured to stick to this implementation if you feel there is a better way)
public static IApplicationBuilder UseRulesEngineDashboard(
this IApplicationBuilder app,
Action<DashboardOptions> action = null!)
{
var options = new DashboardOptions();
action?.Invoke(options);
var env = app.ApplicationServices.GetRequiredService<IWebHostEnvironment>();
#if LOCAL_DEV
app.MapWhen(context => context.Request.Path.StartsWithSegments(options.BaseUrl), builder =>
{
builder.UseSpa(spa =>
{
spa.UseProxyToSpaDevelopmentServer(options.ApiUrl);
});
});
#else
app.MapWhen(context => context.Request.Path.StartsWithSegments(options.BaseUrl), builder =>
builder.Run(async context =>
{
await context.Response.WriteAsync("Hello World");
}));
#endif
return app;
}