3

I want to use bundle transformer to bundle and minify my css collection , but however i tried it doesn't work

heres my code, please give me some advise, thanks.

        var nullBuilder = new NullBuilder();
        var cssTransformer = new StyleTransformer(new CleanCssMinifier());
        var nullOrderer = new NullOrderer();

        BundleResolver.Current = new CustomBundleResolver();

        var commonStylesBundle = new Bundle("~/bundles/css/site");
        commonStylesBundle.IncludeDirectory("~/Content/sass", "*.css");

        commonStylesBundle.Builder = nullBuilder;
        commonStylesBundle.Transforms.Add(cssTransformer);
        commonStylesBundle.Orderer = nullOrderer;

        bundles.Add(commonStylesBundle);

it always output the html like this:

<link href="/Content/sass/card.css?bundleVirtualPath=%7e%2fbundles%2fcss%2fsite" rel="stylesheet"/>
<link href="/Content/sass/header.css?bundleVirtualPath=%7e%2fbundles%2fcss%2fsite" rel="stylesheet"/>
<link href="/Content/sass/login.css?bundleVirtualPath=%7e%2fbundles%2fcss%2fsite" rel="stylesheet"/>
3
  • You running in debug? Make sure BundleTable.EnableOptimizations is set to true. Commented May 17, 2015 at 21:41
  • ohh, i forgot switch this var to true, thanks. Commented May 17, 2015 at 21:46
  • but, is it can be switch in config file, not cs file Commented May 17, 2015 at 21:47

1 Answer 1

3

you need to set debug mode as false in the config. Or alternatively do the following in code-

BundleTable.EnableOptimizations = true;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.