Created
January 10, 2014 06:31
-
-
Save yngvebn/8347809 to your computer and use it in GitHub Desktop.
Workaround for invalid Media Query minification (WebGrease and System.Web.Optimization)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BundleConfig | |
{ | |
public static void RegisterBundles(BundleCollection bundles) | |
{ | |
var siteCssBundle = new StyleBundle("~/css/site").IncludeDirectory("~/public/css", "*.css"); | |
siteCssBundle.Transforms.Clear(); | |
siteCssBundle.Transforms.Add(new CustomCssMinify()); | |
bundles.Add(siteCssBundle); | |
} | |
} | |
public class CustomCssMinify : CssMinify | |
{ | |
public override void Process(BundleContext context, BundleResponse response) | |
{ | |
// Workaround for a bug in WebGrease/System.Web.Optimization | |
// missing leading whitespace before 'and', 'not', 'only' | |
// hopefully a fix will come! | |
base.Process(context, response); | |
response.Content = response.Content | |
.Replace(")and ", ") and ") | |
.Replace(")not ", ") not ") | |
.Replace(")only ", ") only "); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would assume that this is only called once when changes are detected?