-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from PrincipleStudios/vite-development-server
Vite development server
- Loading branch information
Showing
36 changed files
with
2,555 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: All packages build | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: | ||
- '**/*' | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/workflows/parts/cache/ | ||
|
||
########### | ||
# BUILD | ||
- name: Restore dependencies | ||
run: dotnet restore | ||
- name: Build | ||
run: | | ||
if [[ $VERSION_SUFFIX ]]; then | ||
VERSION_SUFFIX_PARAM="--version-suffix sha.$VERSION_SUFFIX" | ||
else | ||
VERSION_SUFFIX_PARAM='' | ||
fi | ||
dotnet build --no-restore --configuration Release ${VERSION_SUFFIX_PARAM} | ||
env: | ||
VERSION_SUFFIX: ${{ github.ref != 'refs/heads/main' && github.sha || '' }} | ||
|
||
########### | ||
# TEST | ||
- name: Test | ||
run: dotnet test --no-build --verbosity normal --configuration Release --collect:"XPlat Code Coverage" | ||
# - name: 'Upload Code Coverage' | ||
# uses: actions/upload-artifact@v3 | ||
# with: | ||
# name: code-coverage | ||
# path: ./lib/*/TestResults/*/coverage.cobertura.xml | ||
# retention-days: 7 | ||
# - name: Record code coverage | ||
# uses: 5monkeys/cobertura-action@master | ||
# with: | ||
# path: ./lib/*/TestResults/*/coverage.cobertura.xml | ||
# repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
# minimum_coverage: 90 | ||
# fail_below_threshold: false | ||
|
||
########### | ||
# PUBLISH | ||
- name: Publish NuGet packages to GitHub registry if new version number | ||
if: ${{ github.ref != 'refs/heads/main' }} | ||
run: dotnet nuget push ./artifacts/packages/Release/*.nupkg -k ${GITHUB_TOKEN} -s https://nuget.pkg.github.com/$GITHUB_REPOSITORY_OWNER/index.json --skip-duplicate --no-symbols | ||
continue-on-error: true # Dependabot and other outside contributors can't push to our GitHub packages | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Publish NuGet packages to NuGet registry if new version number | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
run: dotnet nuget push ./artifacts/packages/Release/*.nupkg -k ${NUGET_API_KEY} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols | ||
env: | ||
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Lint DotNet | ||
on: | ||
pull_request: | ||
types: [edited, opened, reopened, synchronize, ready_for_review] | ||
|
||
jobs: | ||
build: | ||
runs-on: 'ubuntu-latest' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/workflows/parts/cache/ | ||
- name: 'Run dotnet checks' | ||
run: | | ||
dotnet format --verify-no-changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: 'Package Cache' | ||
description: 'Caches packages for this repository' | ||
inputs: {} | ||
outputs: {} | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: '8.0.x' | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20.8.1 | ||
|
||
- uses: actions/cache@v3 | ||
with: | ||
path: ~/.nuget/packages | ||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} | ||
restore-keys: | | ||
${{ runner.os }}-nuget- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v20.8.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.vite/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using PrincipleStudios.ViteDevelopmentServer.Demo; | ||
|
||
Host.CreateDefaultBuilder(args) | ||
.ConfigureWebHostDefaults(webBuilder => | ||
{ | ||
webBuilder.UseStartup<Startup>(); | ||
}) | ||
.Build() | ||
.Run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:64422", | ||
"sslPort": 44363 | ||
} | ||
}, | ||
"profiles": { | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "http://localhost:5052", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"https": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "https://localhost:7120;http://localhost:5052", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace PrincipleStudios.ViteDevelopmentServer.Demo; | ||
|
||
public class Startup | ||
{ | ||
private readonly IWebHostEnvironment env; | ||
|
||
public Startup(IWebHostEnvironment env) | ||
{ | ||
this.env = env; | ||
} | ||
|
||
|
||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddSpaStaticFiles(configuration => | ||
{ | ||
configuration.RootPath = "ui/dist"; | ||
}); | ||
} | ||
|
||
public void Configure(IApplicationBuilder app) | ||
{ | ||
// Keep stray POSTs from hitting the SPA middleware | ||
// Based on a comment in https://github.com/dotnet/aspnetcore/issues/5192 | ||
app.MapWhen(context => context.Request.Method == "GET" || context.Request.Method == "CONNECT", (when) => | ||
{ | ||
app.UseSpaStaticFiles(); | ||
app.UseSpa(spa => | ||
{ | ||
spa.Options.SourcePath = "ui"; | ||
|
||
spa.UseViteDevelopmentServer("node_modules/.bin/vite", "--port {port}"); | ||
}); | ||
}); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
ViteDevelopmentServer.Demo/ViteDevelopmentServer.Demo.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<RootNamespace>PrincipleStudios.ViteDevelopmentServer.Demo</RootNamespace> | ||
<UiDir>$(ProjectDir)ui\</UiDir> | ||
<NpmInstallRecordPath>$(UiDir)node_modules\_$(Configuration)._</NpmInstallRecordPath> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ViteDevelopmentServer\ViteDevelopmentServer.csproj" /> | ||
</ItemGroup> | ||
|
||
<Target Name="NpmInstall" BeforeTargets="BeforeBuild" Inputs="$(UiDir)package.json;$(UiDir)package-lock.json" Outputs="$(NpmInstallRecordPath)"> | ||
<Exec WorkingDirectory="$(UiDir)" Condition=" $(Configuration) != 'Release' " Command="npm install" /> | ||
<Exec WorkingDirectory="$(UiDir)" Condition=" $(Configuration) == 'Release' " Command="npm ci" /> | ||
<!-- On either build, mark that it succeeded so it skips and goes fast next time... if there's no changes to package*.json --> | ||
<Touch AlwaysCreate="true" ForceTouch="true" Files="$(NpmInstallRecordPath)" /> | ||
</Target> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/white-book.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite Demo</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module"> | ||
import ReactDOM from 'react-dom/client' | ||
import { AppElement } from './src/main.tsx' | ||
|
||
ReactDOM.createRoot(document.getElementById('root')).render(AppElement); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.