Skip to content

Instantly share code, notes, and snippets.

@cpoDesign
Last active April 9, 2017 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpoDesign/3a0b8bf54c99d339db651bf3030bc8c8 to your computer and use it in GitHub Desktop.
Save cpoDesign/3a0b8bf54c99d339db651bf3030bc8c8 to your computer and use it in GitHub Desktop.
public class SiteStartupHandler : IApplicationEventHandler
{
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication,ApplicationContext applicationContext)
{
// Register bunding for umbraco
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/site.css").Include(
"~/content/style.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/site.js").Include(
"~/scripts/example.js"
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment