Skip to content

Instantly share code, notes, and snippets.

@aweber1
Created January 10, 2019 20:49
Show Gist options
  • Save aweber1/118cc4fd0f23744e188f623ebce35547 to your computer and use it in GitHub Desktop.
Save aweber1/118cc4fd0f23744e188f623ebce35547 to your computer and use it in GitHub Desktop.
JSS Server ConfigurationResolver patch. For JSS 11 (GA), on both Sitecore 9.0.2 and 9.1
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<services>
<configurator
type="Sitecore.JavaScriptServices.CustomConfiguration.RegisterDependenciesPatch, [YOUR DLL NAME HERE]"
patch:after="*[@type='Sitecore.JavaScriptServices.Configuration.RegisterDependencies, Sitecore.JavaScriptServices.Configuration']" />
</services>
</sitecore>
</configuration>
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using Sitecore.DependencyInjection;
using Sitecore.JavaScriptServices.Configuration;
namespace Sitecore.JavaScriptServices.CustomConfiguration
{
public class RegisterDependenciesPatch : IServicesConfigurator
{
public void Configure(IServiceCollection serviceCollection)
{
var toRemove = serviceCollection.FirstOrDefault(d => d.ServiceType == typeof(IConfigurationResolver));
serviceCollection.Remove(toRemove);
serviceCollection.AddSingleton<IConfigurationResolver, ConfigurationResolver>();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment