Skip to content

SPA Module

Warning

The usage of this module for a Microservices architecture is discouraged. If you think you need this module, contact the Suite Team.

The SpaModule supports serving web frontends inside the ASP.NET Pipeline.

The web resources are included as embedded resources in your module's assembly. The SpaModule includes support for building your web frontend together with your module through MSBuild.

Build target

If you'd like to auto build the frontend together with your module, you'll need to add the SpaModule targets file to your .csproj file, the reason being that we are not using NuGet packages.

XML
<Project Sdk="Microsoft.NET.Sdk.Web">
    <Import Project="$(ModulesPath)ITsynch.Suite.SpaModule\ITsynch.Suite.SpaModule.targets" />

    <PropertyGroup Condition=" '$(Configuration)'=='Debug' ">
        <!--Will execute the BuildScript at the AngularPath and embedded the SpaArtifactsPath into the assembly.-->
        <RunSpaTarget>true</RunSpaTarget>
        <RunSpaBuild>false</RunSpaBuild>
        <BuildScript>nx build itsynch-suite --prod</BuildScript>
        <AngularPath>$([System.IO.Path]::GetFullPath($(SolutionDir)\..\angular))</AngularPath>
        <SpaArtifactsPath>$(AngularPath)\dist\apps\itsynch-suite</SpaArtifactsPath>
    </PropertyGroup>
</Project>
  1. RunSpaTarget will run the build of the spa and copy the artifacts.
  2. AngularPath The path where your angular project is located, it is used to run the builds.
  3. SpaArtifactsPath The folder where you Spas applications are located.
  4. BuildScript This script will run on the specified AngularPath.
  5. RunSpaBuild If true, the spa module target will run the build inside the configured AngularPath.
  6. RunArtifactsCopy If true, the target will add as embedded resources all the files contained inside the SpaArtifactsPath.

Info

The embedded resources will be embedded in the path: [moduleName].spa.[containerFolderOfYourSpa]

Configure the SpaModule

To install the SpaModule, you simply depend on the SpaModule and configure it, like so:

C#
public void SetupModule(IModuleBuilder builder)
{
    builder.DependsOn<SPAProviderModule, SPAProviderModuleOptions>(options =>
    {
            builder.DependsOn<SpaModule, SpaModuleOptions>(options =>
            {
                options.FilesPath = "myAppAssemblyName.spa.itsynch_suite";
                options.Assembly = Assembly.GetExecutingAssembly();
            });
    });
}

Tip

Use a dedicated project uniquely for this deployment scenario in order to prevent duplicate builds.