Reputation: 3200
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
Reputation: 18974
Here's two possible causes:
@ 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
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
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