curiousBoy
curiousBoy

Reputation: 6834

Avoid specific css to be minified in MVC bundleconfig

In MVC BundleConfig.cs, when the debug=false or BundleTable.EnableOptimizations = true; it minifies the scripts and css files, but what if I want explicitly avoid specific one that should not be minified?

I have one problematic css file which is broken as soon as it is minified. So I would like to keep only that one as it is. (please do not suggest fixing that broken css etc...)

I mean as an example:

 bundles.Add(new StyleBundle("~/Content/css").Include( 
                    "~/Content/myStyle1.css",
                    "~/Content/myStyle2.css",
                    "~/Content/myStyle3.css",
                    "~/Content/myStyleDoNotMinify.css" 
                )); 

How to exclude the last one to not be minified, but still included?

Should I just not use the bundle config at all for that specific css?

Upvotes: 0

Views: 289

Answers (1)

Arachchi
Arachchi

Reputation: 26

As you suggested you can link the file "myStyleDoNotMinify.css" separately without adding into the bundle. If you would like to include all the css files in a folder and just exclude this file you may use the ignore list.

bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/*.css"));

BundleTable.Bundles.IgnoreList.Ignore("myStyleDoNotMinify.css", OptimizationMode.Always);

Upvotes: 1

Related Questions