Thats the way it's done in a v6 setup we're using.
Haven't tryed it in v7 but should also work like this.
Make a class that inherits from IApplicationEventHandler and then add this code:
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
RegisterStyles(BundleTable.Bundles);
RegisterJavascript(BundleTable.Bundles);
}
private static void RegisterStyles(BundleCollection bundles)
{
//Add all style files. These will be bundled and minified.
//After everything has been bundled (which only happens when debug=false in the web.config) check if there are no errors in the bundled file. Not all files can be bundled.
bundles.Add(new StyleBundle("~/bundle/styles.css").Include(
"~/css/main.css"
)
);
}
private static void RegisterJavascript(BundleCollection bundles)
{
//Add all javascript files. These will be bundled and minified.
//After everything has been bundled (which only happens when debug=false in the web.config) check if there are no errors in the bundled file. Not all files can be bundled.
bundles.Add(new ScriptBundle("~/bundle/javascript.js").Include(
"~/umbraco/plugins/TrackMedia/Tracking.js",
"~/scripts/jquery.validate.js",
"~/scripts/slimmage.js",
"~/scripts/functions.js"
)
);
}
Bundles
Hi
Using System.Web.Optimization, can anyone tell me how to tell Umbraco 7 to let me add my own bundles please?
Previously i would edited global, but that's compiled now, and used a BundleConfig.cs file in App_Start.
Thanks
Thats the way it's done in a v6 setup we're using.
Haven't tryed it in v7 but should also work like this. Make a class that inherits from IApplicationEventHandler and then add this code:
Comment author was deleted
Or just use http://our.umbraco.org/projects/developer-tools/optimus
ah, that seems simpler!
thanks
For thoose who looks here and goes with David Brendels code, Here's an addition the that post.
When adding bundles, don't add extensions, like .js or .css, it should be like "~/bundles/script" for instance. See http://www.asp.net/mvc/overview/performance/bundling-and-minification for reference.
Also you'll have to add the bundle path to the reserved paths. Like this ->
<add key="umbracoReservedPaths" value="~/umbraco,~/install/,~/bundles/"/>
Otherwise the umbraco route-engine will try to map the path to a page (since we don't want ant extension in the bundle)
Another solution is to use Cruncher - https://github.com/JimBobSquarePants/Cruncher
Thanks
If you are using Cruncher on an Azure web app be sure to set the platform in application settings to 64 bit or it YSODS. :S
is working on a reply...