Last active
December 21, 2015 11:38
-
-
Save andrewbranch/6300376 to your computer and use it in GitHub Desktop.
Bundling with BundleTransformer in ASP.NET MVC. Less files need to have their Build Action set to "Content" in their file properties in order to publish successfully.
This file contains hidden or 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
using System.Web; | |
using System.Web.Optimization; | |
using BundleTransformer.Core.Transformers; | |
namespace Project { | |
public class BundleConfig { | |
public static void RegisterBundles(BundleCollection bundles) { | |
var styles = new Bundle("~/bundles/stylesheets") | |
.Include( | |
"~/Assets/stylesheets/*.css", | |
"~/Assets/stylesheets/*.less" | |
); | |
styles.Transforms.Add(new CssTransformer()); | |
bundles.Add(new ScriptBundle("~/bundles/javascripts").IncludeDirectory("~/Assets/javascripts/plugins", "*.js").IncludeDirectory("~/Assets/javascripts", "*.js")); | |
bundles.Add(styles); | |
} | |
} | |
} |
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Web.Hosting; | |
using System.Web.Http; | |
using System.Web.Mvc; | |
using System.Web.Optimization; | |
using System.Web.Routing; | |
namespace Project { | |
public class MvcApplication : System.Web.HttpApplication { | |
protected void Application_Start() { | |
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); | |
RouteConfig.RegisterRoutes(RouteTable.Routes); | |
BundleConfig.RegisterBundles(BundleTable.Bundles); | |
} | |
} |
This file contains hidden or 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
<%= Styles.Render("~/bundles/stylesheets") %> | |
<%= Scripts.Render("~/bundles/javascripts") %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment