CSS minification and bundling replaces 0px with 0 in calc, so content doesn't render properly

694 views Asked by At

I'm using Microsoft.AspNet.Web.Optimization (1.1.3) from an MVC 5.1 site to bundle and minify my CSS and it is replacing values of 0px with 0 in release mode and this causes rendering issues. Is it possible to stop this behavior somehow?

This css

min-width: -webkit-calc((240px + 0px + 550px + 0px + 240px + 0px));

Is replaced with:

min-width: -webkit-calc((240px + 0 + 550px + 0 + 240px + 0));

1

There are 1 answers

0
chrisp_68 On

Given that the css is already minified when Compass compiles the SASS to CSS, I have opted to remove the transforms.

private static void DontMinifyStyleBundles(IEnumerable<Bundle> bundles)
{
    // SASS is already minified by compass at build time and the default asp.net minification 
    // causes 0px in calc() to be set to 0 which causes rendering problems.
    foreach (var bundle in bundles)
    {
        bundle.Transforms.Clear();
    }
}