user636525
user636525

Reputation: 3200

how to debug Minification failed. Returning unminified contents

I am using Asp.net MVC 4 bundler to bundle and minify my Css files.

YSlow is showing this error below

 /* Minification failed. Returning unminified contents.
    (1442,26): run-time error CSS1019: Unexpected token, found ':'
    (1442,26): run-time error CSS1042: Expected function, found ':'
    (1442,26): run-time error CSS1062: Expected semicolon or closing curly-brace, found ':'
     */

This is my bundle code,

    bundles.Add(new StyleBundle("~/Content/css").Include(
        "~/Content/site.css",
        "~/Content/fullcalendar.css",
        "~/Content/jquery.dropdown.css",
        "~/Content/jquery.tagit.css",
        "~/Content/tipsy.css"
        ));

Now how will i find out which css file is causing the problem ? How can i debug to find the line that is causing the problem ? site.css is the only css file that i wrote.

Upvotes: 28

Views: 26318

Answers (3)

Amirhossein Mehrvarzi
Amirhossein Mehrvarzi

Reputation: 18974

Here's two possible causes:

  • The invalid CSS files that should be validated before bundling. here is W3C CSS validation service to meet this purpose.
  • Also considering that Microsoft Optimizer reads content of target resources for minification process, so by using some special phrases like @ sourceMappingURL=jquery.min.map in a JavaScript file or @charset "UTF-8"; in a styleSheet file, the Minification will be failed again. So try to remove or commentize them.

Note that by default, Bundling process can't build relative path of image resources in css or js files.

Relative Image Path Solution:

You can use the same path as bundling path like:

bundles.Add(new StyleBundle("~/Content/css/jquery-ui/bundle")
       .Include("~/Content/css/jquery-ui/*.css"));

Where you define the bundle on the same path as the source files that made up the bundle, the relative path of image resources will still work( i.e. /bundle can be any name you like).

Or using new CssRewriteUrlTransform() as second parameter like:

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

Upvotes: 2

Carlos Martinez T
Carlos Martinez T

Reputation: 6528

In case someone is still dealing with problems like this.

In the example above: (1442,26) 1442 is the line number and 26 is the character offset. HOWEVER, for this to be exact, you need remove the whole comment where this error is indicated:

 /* Minification failed. Returning unminified contents.
    (1442,26): run-time error CSS1019: Unexpected token, found ':'
    (1442,26): run-time error CSS1042: Expected function, found ':'
    (1442,26): run-time error CSS1062: Expected semicolon or closing curly-brace, found ':'
     */

Upvotes: 41

user636525
user636525

Reputation: 3200

filter: alpha(opacity: 0); was the line that was causing the issue. After i removed this line i was able to minify the css file without any issue,

Upvotes: 1

Related Questions