Skip to content

Can I use RequestReduce in my build process to generate sprites and new css and javascript before deployment instead of using the filter?

mwrock edited this page Oct 15, 2011 · 2 revisions

A future release of RequestReduce will provide a proper command line solution for processing javascript, css and sprites on a given set of css files. However, it is possible to interact with the RequestReduce.dll to invoke its Redcucer operations on a set of css and javascript files. Here is an example:

var config = RRContainer.Current.GetInstance<IRRConfiguration>();
config.SpritePhysicalPath = "c:\\RequestReduce.SampleWeb\\RequestReduceContent";
string processedCssUrl = string.Empty;
string processedJsUrl = string.Empty;
IReducer reducer = null;
using(reducer = var reducer = RRContainer.Current.GetInstance<CssReducer>())
{
    var cssToProcess = "http://localhost/Styles/style1.css::http://localhost/Styles/style2.css";
    processedCssUrl= reducer.Process(urls);
}
using(reducer = var reducer = RRContainer.Current.GetInstances<JavaScriptReducer>())
{
    var jsToProcess = "http://localhost/Scripts/script1.js::http://localhost/Scripts/script2.js";
    processedJsUrl = reducer.Process(urls);
}

processedCssUrl and processedJsUrl should be the absolute urls to the css and javascript files generated by RequestReduce.

Clone this wiki locally