DarkPatterns.ProxyDevelopmentServer
0.1.0
dotnet add package DarkPatterns.ProxyDevelopmentServer --version 0.1.0
NuGet\Install-Package DarkPatterns.ProxyDevelopmentServer -Version 0.1.0
<PackageReference Include="DarkPatterns.ProxyDevelopmentServer" Version="0.1.0" />
paket add DarkPatterns.ProxyDevelopmentServer --version 0.1.0
#r "nuget: DarkPatterns.ProxyDevelopmentServer, 0.1.0"
// Install DarkPatterns.ProxyDevelopmentServer as a Cake Addin #addin nuget:?package=DarkPatterns.ProxyDevelopmentServer&version=0.1.0 // Install DarkPatterns.ProxyDevelopmentServer as a Cake Tool #tool nuget:?package=DarkPatterns.ProxyDevelopmentServer&version=0.1.0
DarkPatterns.ProxyDevelopmentServer
A development server for use with .NET Spa Services. This works very similarly
to the UseReactDevelopmentServer
middleware provided by the .NET Spa Services
project.
Note: This server is intended for development purposes only; it is not optimized for production.
Add your project reference to your csproj; be sure to exclude it for release builds:
<ItemGroup>
<PackageReference Include="DarkPatterns.ProxyDevelopmentServer" Version="0.1.0" Condition=" '$(Configuration)' == 'Debug' " />
</ItemGroup>
Usage example:
app.UseSpa(spa => {
#if DEBUG
if (env.IsDevelopment())
{
spa.Options.SourcePath = "./path-to-working-directory";
spa.UseProxyDevelopmentServer(DarkPatterns.ProxyDevelopmentServer.ProxyDevelopmentServerOptions.PnpmViteServer);
// or
spa.UseProxyDevelopmentServer(DarkPatterns.ProxyDevelopmentServer.ProxyDevelopmentServerOptions.DefaultViteServer);
// or
spa.UseProxyDevelopmentServer(new()
{
// fill in your own details
});
}
#endif
});
The fully-qualified namespace is provided so that the #if DEBUG
does not need
to be added in the using statements.
spa.Options.SourcePath
is the working directory (relative to your application's working directory) in which to run the proxy server.ProxyDevelopmentServerOptions
has a few default configurations:ProxyDevelopmentServerOptions.PnpmViteServer
runs a Vite dev server via the PNPM command line.ProxyDevelopmentServerOptions.DefaultViteServer
runs a Vite dev server via thenode_modules/.bin/vite
path.
If you have a setup that doesn't use one of the standard scenarios, you can set up your own configuration:
IsScriptFile
indicates if the file being targeted is a script. If false, it is assumed that the command is on the path and does not need additional modification (on non-Windows machines, see below.)BaseCommand
is the name of the executable or script to launch, such aspnpm
ornode_modules/.bin/vite
.Parameters
are the command-line arguments to be passed to the script. These should be already-escaped values and quoted as necessary.ReadyText
is the text to search for within the Standard Out of the command to know that the proxy is ready. This is parsed as a regular expression, and evaluated against each complete line returned from the command (prior to any filters).Timeout
is how long to expect to wait for theReadyText
. If the timeout is exceeded, the application will not start. Note that this is used in conjunction with thespaBuilder.Options.StartupTimeout
; if either times out before the proxy is ready, the application will not start.
See the demo and test projects for more usage details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.AspNetCore.SpaServices.Extensions (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.1.0 | 187 | 10/30/2024 |