Skip to content

Commit 7cddef7

Browse files
Use RCL and client assets restore/build MSBuild targets
1 parent 1430a35 commit 7cddef7

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed
Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,53 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk.Razor">
22
<PropertyGroup>
33
<AssemblyName>Our.Umbraco.UiExamples</AssemblyName>
44
<TargetFramework>net9.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7+
<StaticWebAssetBasePath>/App_Plugins/Example.UI</StaticWebAssetBasePath>
8+
<NoWarn>$(NoWarn),NU1902</NoWarn>
79
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
13+
<SupportedPlatform Include="browser" />
14+
</ItemGroup>
15+
816
<ItemGroup>
917
<PackageReference Include="Umbraco.Cms.Web.Common" VersionOverride="[15.0.0, 16)" />
1018
</ItemGroup>
19+
20+
<!-- Client assets restore and build -->
21+
<ItemGroup>
22+
<ClientAssetsInputs Include="package.json;package-lock.json;tsconfig.json;vite.config.js;src\**;public\**" Exclude="$(DefaultItemExcludes)" />
23+
<Content Update="$(ClientAssetsInputs)\**" Pack="false" />
24+
</ItemGroup>
25+
26+
<Target Name="ClientAssetsRestore" Inputs="package-lock.json" Outputs="node_modules\.package-lock.json">
27+
<Message Importance="high" Text="Restoring NPM packages..." />
28+
<Exec Command="npm ci --no-fund --no-audit --prefer-offline" />
29+
</Target>
30+
31+
<Target Name="ClientAssetsBuild" DependsOnTargets="ClientAssetsRestore" BeforeTargets="AssignTargetPaths" Inputs="@(ClientAssetsInputs)" Outputs="$(IntermediateOutputPath)clientassetsbuild.complete.txt">
32+
<Message Importance="high" Text="Executing NPM build script..." />
33+
<PropertyGroup>
34+
<_ClientAssetsOutputFullPath>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)clientassets'))/</_ClientAssetsOutputFullPath>
35+
</PropertyGroup>
36+
<MakeDir Directories="$(_ClientAssetsOutputFullPath)" />
37+
<Exec Command="npm run build -- --outDir &quot;$(_ClientAssetsOutputFullPath)&quot;" />
38+
<ItemGroup>
39+
<_ClientAssetsBuildOutput Include="$(IntermediateOutputPath)clientassets\**"></_ClientAssetsBuildOutput>
40+
</ItemGroup>
41+
<WriteLinesToFile File="$(IntermediateOutputPath)clientassetsbuild.complete.txt" Lines="@(_ClientAssetsBuildOutput)" Overwrite="true" />
42+
</Target>
43+
44+
<Target Name="DefineClientAssets" AfterTargets="ClientAssetsBuild" DependsOnTargets="ResolveStaticWebAssetsConfiguration">
45+
<ItemGroup>
46+
<FileWrites Include="@(_ClientAssetsBuildOutput)" />
47+
<FileWrites Include="$(IntermediateOutputPath)clientassetsbuild.complete.txt" />
48+
</ItemGroup>
49+
<DefineStaticWebAssets CandidateAssets="@(_ClientAssetsBuildOutput)" SourceId="$(PackageId)" SourceType="Computed" ContentRoot="$(_ClientAssetsOutputFullPath)" BasePath="$(StaticWebAssetBasePath)">
50+
<Output TaskParameter="Assets" ItemName="StaticWebAsset" />
51+
</DefineStaticWebAssets>
52+
</Target>
1153
</Project>

src/Our.Umbraco.UiExamples.v15/public/vite.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/Our.Umbraco.UiExamples.v15/vite.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { defineConfig } from "vite";
2-
import {glob} from 'glob';
2+
import { glob } from 'glob';
33
import path from 'node:path';
44
import { fileURLToPath } from 'node:url';
55

@@ -9,7 +9,7 @@ export default defineConfig({
99
entry: ["src/dashboards/welcome-dashboard.ts"], // your web component source file
1010
formats: ["es"],
1111
},
12-
outDir: "../../examples/Umbraco15.Website/App_Plugins/Example.UI", // your web component will be saved in this location
12+
outDir: "obj/Debug/net9.0/clientassets", // your web component will be saved in this location
1313
sourcemap: true,
1414
rollupOptions: {
1515
input: Object.fromEntries(

0 commit comments

Comments
 (0)