Assman will keep track of the dependencies between both scripts and stylesheets.
Dependencies are auto included
request that a script be included on the page
, Assman will look to see if that script has any dependencies. If it does, then it will ensure that its dependencies are also included first on the page. It works the same for stylesheets.
Dependencies and Consolidation
If a dependency is consolidated into the same script/stylsheet as the resource that depends on it, then the dependency resource's content will appear first in the consolidated resource.
/// <reference path="~/path/to/my/dependency.js" />
Visual Studio will automatically use the scripts defined in the dependency.js file to populate its intellisense. ReSharper 6 also supports this syntax. Assman piggybacks off of this approach and by default, peeks into your scripts looking for these declared
references and tracks them as dependencies of the script they are declared in.
Since there is no way I know of for css stylesheets to declare dependencies on other stylesheets, Assman had to invent its own. (yes, there is an @import statement in css, but that actually has functionality attached to it that you don't necessarily want
when you are consolidating your stylesheets)
To declare a dependency in a css stylesheet on another css stylesheet, you simple need to use this syntax (I suggest it be in a comment block, though it isn't required):
Customizing how dependencies are declared
The mechanism that Assman uses to figure out what dependencies a given resource has is extensible and can be customized on a per file extension basis. Assman uses the IDependencyProvider interface to get dependencies for a resource. That interface has one method
that looks like this:
IEnumerable<string> GetDependencies(IResource resource);
The GetDependencies method takes an IResource and returns a virtual path to all of that resources dependencies.
To hook up your custom IDependencyProvider, you need to write an
. In the plugin's Initialize method, you then just need to map your instance of IDependencyProvider to the file extension(s) you wish to have it used for. It would look something like this:
public void Initialize(AssmanContext context)
context.MapDependencyProvider(".js", new MyCustomDependencyProvider());
Disabling Dependency Management
If for whatever reason you don't want Assman to manage your dependencies, you can turn the behavior off by setting the manageDependencies attribute to false in the Assman.config (the attribute would go on the root assman element). It would look like this