Skip to content

Instantly share code, notes, and snippets.

@ferventcoder
Created September 21, 2012 06:16
Show Gist options
  • Save ferventcoder/3759985 to your computer and use it in GitHub Desktop.
Save ferventcoder/3759985 to your computer and use it in GitHub Desktop.
Cassette Configuration
@{
Bundles.Reference("content/Site.css");
Bundles.Reference("Scripts");
Bundles.Reference("Scripts/custom");
}
/// <summary>
/// Bundles the Javascript and CSS files for the web application based on conventions set here.
/// </summary>
public class CassetteConfiguration : ICassetteConfiguration
{
/// <summary>
/// Configures the specified bundles.
/// </summary>
/// <param name="bundles">The bundles.</param>
/// <param name="settings">The settings.</param>
public void Configure(BundleCollection bundles, CassetteSettings settings)
{
// Configure your bundles here...
// Please read http://getcassette.net/documentation/configuration
// This default configuration treats each file as a separate 'bundle'.
// In production the content will be minified, but the files are not combined.
// So you probably want to tweak these defaults!
//bundles.AddPerIndividualFile<StylesheetBundle>("Content");
//bundles.AddPerIndividualFile<ScriptBundle>("Scripts");
// bundles.AddPerSubDirectory<StylesheetBundle>("Content");
bundles.AddPerIndividualFile<StylesheetBundle>("Content",new FileSearch
{
Pattern = "*.css",
SearchOption = SearchOption.AllDirectories,
});
if (ApplicationParameters.IsDebug)
{
bundles.AddPerSubDirectory<ScriptBundle>("Scripts", new FileSearch
{
Pattern = "*.js;*.coffee",
SearchOption = SearchOption.AllDirectories,
Exclude = new Regex("-vsdoc\\.js$|\\.min\\.js$")
});
}
else
{
bundles.AddPerSubDirectory<ScriptBundle>("Scripts", new FileSearch
{
Pattern = "*.js;*.coffee",
SearchOption = SearchOption.AllDirectories,
Exclude = new Regex("-vsdoc\\.js$|\\.min\\.js$|\\.debug\\.js$")
});
}
this.Log().Debug(() => "Cassette is now configured...");
// To combine files, try something like this instead:
// bundles.Add<StylesheetBundle>("Content");
// In production mode, all of ~/Content will be combined into a single bundle.
// If you want a bundle per folder, try this:
// bundles.AddPerSubDirectory<ScriptBundle>("Scripts");
// Each immediate sub-directory of ~/Scripts will be combined into its own bundle.
// This is useful when there are lots of scripts for different areas of the website.
// *** TOP TIP: Delete all ".min.js" files now ***
// Cassette minifies scripts for you. So those files are never used.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment