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.
- 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" );
}
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 theDevelopment
environment name.