Documentation

Add Directory

A bundle can be added using the contents of directory.

public class CassetteConfiguration : ICassetteConfiguration
{
    public void Configure(BundleCollection bundles, CassetteSettings settings)
    {
        bundles.Add<StylesheetBundle>("Content");
    }
}

Cassette uses the generic type to determine which files to include. In the above example only .css and .less files are included.

FileSearch

To control which assets are included in the bundle, use an overload of the Add method.

public class CassetteConfiguration : ICassetteConfiguration
{
    public void Configure(BundleCollection bundles, CassetteSettings settings)
    {
        bundles.Add<StylesheetBundle>("Content", new FileSearch
        {
            Pattern = "*.css;*.less",
            SearchOption = SearchOption.AllDirectories, // The default
            Exclude = new Regex("ignore\\.css") // Optional
        });
    }
}

Customizing bundles

The Bundle object created by Cassette can be customized by providing an action delegate.

This is useful for changing the pipeline used to process the bundle.

public class CassetteConfiguration : ICassetteConfiguration
{
    public void Configure(BundleCollection bundles, CassetteSettings settings)
    {
        bundles.Add<StylesheetBundle>(
            "Content",
            bundle => bundle.Processor = new StylesheetPipeline
            {
                ConvertImageUrlsToDataUris = true
            }
        );
    }
}