Skip to content

Instantly share code, notes, and snippets.

@gistlyn
Last active August 28, 2019 19:11
Show Gist options
  • Save gistlyn/4bdb79d21f199c22b8a86f032c186e2d to your computer and use it in GitHub Desktop.
Save gistlyn/4bdb79d21f199c22b8a86f032c186e2d to your computer and use it in GitHub Desktop.
Configure ServiceStack to use Nuglify's Advanced JS/CSS/HTML Minifiers
dotnet add package NUglify
using ServiceStack;
using ServiceStack.Html;
using NUglify;
namespace MyApp
{
public class NUglifyJsMinifier : ICompressor
{
public string Compress(string js) => Uglify.Js(js).Code;
}
public class NUglifyCssMinifier : ICompressor
{
public string Compress(string css) => Uglify.Css(css).Code;
}
public class NUglifyHtmlMinifier : ICompressor
{
public string Compress(string html) => Uglify.Html(html).Code;
}
public class ConfigureNUglify : IConfigureAppHost
{
public void Configure(IAppHost appHost)
{
Minifiers.JavaScript = new NUglifyJsMinifier();
Minifiers.Css = new NUglifyCssMinifier();
Minifiers.Html = new NUglifyHtmlMinifier();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment