Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combining javascript and css files with Rejuicer in ASP.NET MVC

I'm trying to integrate Rejuice (github page is here) to my asp.net mvc project to combine js files. I downloaded it via nuget. It successfully added references and configured web.config file.

In global asax Application_Start I configured it as below:

    OnRequest.ForJs("~/Combined.js")
        .Combine
        .FilesIn("~/Scripts/").Matching("*.js")
        .Configure();

    OnRequest.ForJs("~/Combined.css")
        .Combine
        .FilesIn("~/Style/").Matching("*.css")
        .Configure();

In master page:

<%= Rejuiced.JsFor("~/Combined.js") %>
<%= Rejuiced.CssFor("~/Combined.css")%>

Running project in release mode results in downloading all the js and css files seperately. Running the site under IIS didn't help either. Isn't it supposed to combine and download only 2 files, one for js and another for css? What can cause this problem

like image 470
rovsen Avatar asked Feb 21 '23 11:02

rovsen


1 Answers

Make sure that debug="true" is removed from your your web.config file:

Change

<system.web>
  <compilation debug="true" targetFramework="4.0">

to

<system.web>
  <compilation debug="false" targetFramework="4.0">

It doesn't matter if you build your code in Debug or Release -- Rejuicer respects the web.config debug setting, as it should. If this is set to true, then Rejuicer will not minify and combine files. It does this so that you can debug your scripts using non-minified files when working locally.

When you push your code into Production, your web.config.release transform will run, and remove the debug="true" attribute from your web.config file, so that your files will always be minified in production scenarios.

like image 85
Sam Avatar answered Feb 24 '23 02:02

Sam