-
Notifications
You must be signed in to change notification settings - Fork 0
/
StartupExtensions.cs
26 lines (25 loc) · 1.03 KB
/
StartupExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.Extensions.DependencyInjection;
namespace JsCssReferenceVersionAutoPrefixer
{
public static class StartupExtensions
{
/// <summary>
/// Enables auto prefixing all js/css file refences within cshtml files using a predefined versioning function.
/// Output would be like .jss?v={versionNumber}
/// </summary>
/// <param name="services"></param>
/// <param name="generateVersionFunc">(Optional) Version generator function</param>
public static void AddJsCssVersionAutoPrefixer(this IServiceCollection services,
Func<string> generateVersionFunc = null)
{
VersionTagHelperComponent.VersionFunc = generateVersionFunc
?? VersionTagHelperComponent.GetVersionViaAssemblyLastWriteTime;
services.AddTransient<ITagHelperComponent, VersionTagHelperComponent>();
}
}
}