Davood
Davood

Reputation: 5635

how minify css files works in mvc4?

I'm new in mvc4 i read this article to find what is bundle and minify in mvc4

http://go.microsoft.com/fwlink/?LinkId=254725

i create an new sample project to test css minifing and add tree css file in my theme folder and

public class BundleConfig
{

    public static void RegisterBundles(BundleCollection bundles)
    {

        bundles.Add(new StyleBundle("~/Content/css").Include(
                    "~/Content/themes/default/public.css",
                    "~/Content/themes/default/home.css",
                    "~/Content/themes/default/footer.css"));
     }

and in my master layout :

 @Styles.Render("~/Content/css")

it works fine but i can not understand minifying because when i look at my net thab on firebug tolls i saw my page loads that three css files I'm confuse on two things

1-why it load that css file is it normally or browser should load one file with all of my css files contains?

2-i should create minifiyng folder and minify my css an remove comments and.. and use theme on my project or i use some configs until mvc do it by itself?

Upvotes: 2

Views: 4205

Answers (2)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038720

Run in your application in Release mode:

<compilation debug="false">

and watch what happens.

Upvotes: 5

mnsr
mnsr

Reputation: 12437

First change it to release mode, as it only works in this mode, not Debug.

If you haven't already done so, in your BundleConfig, add:

        BundleTable.EnableOptimizations = true;

Upvotes: 7

Related Questions