Skip to content

Provides an AbstractStorageProvider and accompanying Module that enable auto-discovery of Xperience Page Builder static files within Razor Class Libraries.

License

Notifications You must be signed in to change notification settings

BizStream/xperience-static-web-assets-storage

Repository files navigation

Static Web Assets Storage License NuGet Version

This package provides an AbstractStorageProvider implementation, and an accompanying Module, that allow Xperience Page Builder to auto-discover static assets bundled from Razor Class Libraries during Localhost development.

Usage

  • Install the package into your Xperience Mvc project:
dotnet add package BizStream.Kentico.Xperience.AspNetCore.StaticWebAssetsStorage

OR

<PackageReference Include="BizStream.Kentico.Xperience.AspNetCore.StaticWebAssetsStorage" Version="x.x.x" />
  • Register the Module (within the Mvc Application only):
using BizStream.Kentico.Xperience.AspNetCore.StaticWebAssetsStorage;
using CMS;

[assembly: RegisterModule( typeof( StaticWebAssetsStorageModule ) )]
  • Configure services in Startup.cs:
using BizStream.Kentico.Xperience.AspNetCore.StaticWebAssetsStorage;
using Kentico.PageBuilder.Web.Mvc;
using Microsoft.Extensions.DependencyInjection;

// ...

public void ConfigureServices( IServiceCollection services )
{
    services.AddControllersWithViews();

    Assembly rclAssembly = /* ... */
    services.AddStaticWebAssetsStorage()
        .AddOptions<PageBuilderBundlesOptions>()
        .ConfigureRCLBundle( rclAssembly, "dist\\PageBuilder" );
}

Configuring Environments

As RCL static assets are included when packed (via dotnet pack or dotnet publish), the StaticWebAssetsStorageProvider only needs to be registered for localhost development environments. If a custom environment name is used for localhost development, expose the environment name to the StaticWebAssetsStorageModule via the StaticWebAssetsStorageOptions.EnvironmentNames option:

using BizStream.Kentico.Xperience.AspNetCore.StaticWebAssetsStorage;
using Kentico.PageBuilder.Web.Mvc;
using Microsoft.Extensions.DependencyInjection;

// ...

public void ConfigureServices( IServiceCollection services )
{
    services.AddControllersWithViews();

    services.AddStaticWebAssetsStorage(
        options => options.EnvironmentNames.Add( "MyCustomEnvironment" )
    );

    // OR, using OptionsBuilder:
    services.AddOptions<StaticWebAssetsStorageOptions>()
        .PostConfigure(
            options => options.EnvironmentNames.Add( "MyCustomEnvironment" )
        );

    // ...
}

StaticWebAssetsStorageOptions.EnvironmentNames is initialized with a default value containing the Development environment name.

About

Provides an AbstractStorageProvider and accompanying Module that enable auto-discovery of Xperience Page Builder static files within Razor Class Libraries.

Resources

License

Stars

Watchers

Forks