Post New Article [art]

Post Title
Content
Tags
Category
Actions
Sites Services
Web
Forms
Web
Pages
Single Page Apps
MVCWeb Api
SignalR
ASP.NET

When installing the latest version of the Microsoft.AspNet.Web.Optimization package (before the Microsoft.Web.Optimization package)  I noticed a dependency on an assembly called WebGrease.

So I started to look around what it is and found the following 2 blog posts:

What is WebGrease?

WebGrease is a suite of tools focused on assisting web developers with optimizing the "static" asset files (JavaScript, CSS) of a web application. The features the initial version includes are:

  • Minification of JavaScript & CSS files
  • Validation of JavaScript files
  • Creation of image sprites from images reference in CSS files.
  • Bundling of CSS & JavaScript files.
  • Auto-version naming of files.

The Web Optimization library uses some of the features WebGrease offers(currently only the Minification features for CSS and JavaScript). In order to use all of the features in WebGrease, there is a command line tool included with the nuget package(WG.exe).

wg.exe <operation switch> -in:<input file/folder> -out:<output file/folder>

The valid operation switches of WG.exe are:

  • -m : Invokes the minification operation on the file(s).
  • -v : Runs a validation pass on javascript file(s) and output the results to the console.
  • -s : Processes css file(s) for images and will attempt to create a image sprite out of them, and create updated copies of the css file(s).
  • -b : Bundles files together into a single output file.
  • -a : This switch will rename files based on their content (hash), and generate a lookup xml file for mapping between the original name and new name.