Created
January 10, 2019 20:49
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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