Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Chad Rosenthal 272 posts 474 karma points
    Feb 23, 2013 @ 17:49
    Chad Rosenthal
    0

    Using MVC 4's bundling and minification

    I'm trying to use MVC 4's bundling and optimization features. They seem more standard and easier to use then client dependency's options.

    I updated umbracoReservedPaths with the virtual path that I used in bundling.

    Then updated the global.asax with:

    RouteConfig.RegisterRoutes(RouteTable.Routes);

     

    And created the following class in App_Start.

        public class BundleConfig
        {
            public static void RegisterBundles(BundleCollection bundles)
            {
                bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                    "~/scripts/jquery-1.9.1.js", 
                    "~/scripts/bootstrap.min.js"));
    
                bundles.Add(new StyleBundle("~/bundles/baseCSS").Include(
                    "~/Content/bootstrap.css",
                    "~/Content/bootstrap-responsive.css"
                    ));
            }
        }

     

    Now my masterlayout.cshtml contains:

    @using System.Web.Optimization
    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = null;
    }
    @Styles.Render("~/bundles/baseCSS")

    But it just renders out a url and not the actual files.

    Ideas?

  • gary 385 posts 915 karma points
    Feb 23, 2013 @ 18:45
    gary
    0

    Hi Chad

    I am running VS2012, if you have this, right-click on the folder you want to bundle/minify, web essentials (you may need to install if not already there), then minify css or create bundle, creates new folder, drap and drop into -Layout and that's it. The folder created allows you to add / subtract so no need to worry too much)

    Don't know of another way, but that route is simple enough.

    Hope it helps G

     

     

  • Chad Rosenthal 272 posts 474 karma points
    Feb 23, 2013 @ 18:51
    Chad Rosenthal
    100

    looks like it was probably a configuration issue. I reinstalled twitter bootstrap from nuget and updated the web optimization framework, and then it started to work.

     

  • Tim 166 posts 347 karma points
    Mar 12, 2013 @ 08:51
    Tim
    2

    Just in case anyone else stumbles across this issue and wonders what's going on, in your snippet above you were registering routes not the bundles:

    RouteConfig.RegisterRoutes(RouteTable.Routes);

    Should have been:

    BundleConfig.RegisterBundles(BundleTable.Bundles);
Please Sign in or register to post replies

Write your reply to:

Draft