- Add
.gitignore
to static assets project withwwwroot/
- Update vite configuration with outDir
"../wwwroot/"
- Remove
Build\Microsoft.AspNetCore.ClientAssets.targets
- Create
Build\ClientAssets.targets
with the following contents
<Project>
<PropertyGroup>
<ClientAssetsDirectory>Client\</ClientAssetsDirectory>
</PropertyGroup>
<Target Name="NpmInstall" Inputs="$(ClientAssetsDirectory)package.json" Outputs="$(ClientAssetsDirectory)node_modules/.install-stamp">
<Message Text="NPM Install" Importance="High" />
<Exec WorkingDirectory="$(ClientAssetsDirectory)" Command="npm ci --no-fund --no-audit --prefer-offline" />
<Touch Files="$(ClientAssetsDirectory)node_modules/.install-stamp" AlwaysCreate="true" />
</Target>
<Target Name="NpmBuild" DependsOnTargets="NpmInstall" BeforeTargets="BeforeBuild">
<Message Text="NPM Build" Importance="High" />
<Exec WorkingDirectory="$(ClientAssetsDirectory)" Command="npm run build" />
</Target>
</Project>
- Configure static assets proj file with
- Set
<StaticWebAssetBasePath>App_Plugins/{YOUR_PKG_ALIAS}</StaticWebAssetBasePath>
- Remove
<EnableDefaultContentItems>false</EnableDefaultContentItems>
- Remove
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
- Remove
<Content Include="Views\**" />
- Remove
<Import Project="build\Microsoft.AspNetCore.ClientAssets.targets" />
- Remove
<Target Name="ClientAssetsBuildOutputPath" AfterTargets="ClientAssetsBuild">...</Target>
- Add
<Import Project="Build\ClientAssets.targets" />
to proj file
- In visual studio go to Tools -> Options -> Projects and Solutions -> ASP.NET Core
- Set
Auto build and refresh option
toAuto build and refresh browser after saving
- Set
CSS hot reload
toEnabled
- In visual studio go to Tools -> Options -> Debugging -> .NET/C++ Hot Reload
- Check all checkbox options to
true