Documentation

Add Per Sub-Directory

In a large application it's good to separate related assets into directories. Each directory can then be a Cassette bundle.

Here's an example directory structure:

Scripts/
- Dashboard/
  - header.js
  - popup.js
- Widgets/
  - datepicker.js
  - autocomplete.js
- jquery.js
- underscore.js

We can turn this into three bundles using the AddPerSubDirectory method.

public class CassetteConfiguration : IConfiguration<BundleCollection>
{
    public void Configure(BundleCollection bundles)
    {
        bundles.AddPerSubDirectory<ScriptBundle>("Scripts");
    }
}

A bundle is added for each immediate sub-directory of the given path.

Also, a bundle is created for just top-level assets of the path. This is useful because many third-party nuget packages drop their scripts into ~/Scripts. So it's sensible to move your own scripts into sub-directories.