Minifying, Bundling and Compressing in ASP.NET Core
This repository contains a working sample of how to achieve LESS/SASS pre-processing, Minification, Bundling and GZip Compression of static files on Web Applications running ASP.NET Core (either Full Framework or .Net Core Apps) by using Visual Studio 2015 Extensions as an alternative to NPM+Gulp tasks.
This project uses Mads Kristensen's Bundler & Minifier Extension for bundling and Web Compiler for SASS/LESS pre-processing.
Client libraries are resolved with Bower.
SASS/LESS pre-processing is achieved by using compilerconfig.json. Minification, Bundling and Gzip Compression is achieved by using bundleconfig.json
Both Extensions have their code available on GitHub:
GZip pipeline processing is achieved using a Middleware in Startup.cs:
app.UseStaticFiles(new StaticFileOptions()
{
OnPrepareResponse = (context) =>
{
if ("application/x-gzip".Equals(context.Context.Response.Headers["Content-Type"]))
{
if (context.File.Name.EndsWith("js.gz"))
{
context.Context.Response.Headers["Content-Type"] = "application/javascript";
}
else if (context.File.Name.EndsWith("css.gz"))
{
context.Context.Response.Headers["Content-Type"] = "text/css";
}
context.Context.Response.Headers.Add("Content-Encoding", "gzip");
}
context.Context.Response.Headers.Add("Cache-Control", "public, max-age=2592000");
}
});

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
