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

I am trying to integrate Rejuice (github page here ) into my asp.net mvc project to merge js files. I downloaded it via nuget. He successfully added the links and configured the web.config file.

In the global asax Application_Start, I configured it as shown below:

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

On the home page:

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

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

+4
source share
3 answers

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

Edit

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

to

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

It doesn't matter if you create your code in Debug or Release - Rejuicer respects the debugging setting of web.config, as it should be. If this parameter is set to true, Rejuicer will not minimize and merge files. It does this in such a way that you can debug your scripts using non-minified files in local operation.

When you click your code in Production, your web.config.release conversion will run and remove the debug = "true" attribute from your web.config file so that your files are always minimized in production scripts.

+6
source

I had a very similar problem that was resolved by telling Rejuicer not to do anything in debug mode. However, there is a different way than in the accepted answer to doing this. There are web.config settings that control the behavior of Rejuicer that are not documented (as far as I can see), but I found this by checking the code. Set PreventPassThroughOnDebug to "true":

 <configSections> <section name="compactor" type="Rejuicer.Configuration.CompactorConfiguration, Rejuicer"/> <section name="rejuicer" type="Rejuicer.Configuration.RejuicerConfiguration, Rejuicer"/> </configSections> <compactor Cache="true" Compact="true" Combine="true"/> <rejuicer PreventPassThroughOnDebug="true"/> <!-- THIS IS THE KEY. SET TO "true" --> 
+2
source

Well, I could not get it to work correctly. So I switched to combres . He started working immediately as expected.

0
source

Source: https://habr.com/ru/post/1396736/


All Articles