Last active
August 28, 2019 19:11
-
-
Save gistlyn/4bdb79d21f199c22b8a86f032c186e2d to your computer and use it in GitHub Desktop.
Configure ServiceStack to use Nuglify's Advanced JS/CSS/HTML Minifiers
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
dotnet add package NUglify |
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 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