Dependency Management Got Awesome CommonJS and AMD Compliant dependency loader for modern web apps



Inject.addFileRule(matchesPath, rule, options);

This function allows you to add a rule to transform one path into another during the loading process when a Module ID is associated with a URL.


// if a path contains "nocache", use a different url
Inject.addFileRule(/^https?:]\/\/.*?nocache.*?$/, function(path) {
  return path.replace(/www\.mysite\.com/, '');
}, { weight: 0 });


The matchesPath parameter can either be a string or a regex. If a string, an exact match on the path is required in order to perform a transformation. If matchesPath is a regular expression, then the path is tested against the regex.


The rule object is either a string or a function. If a string, a 1:1 replacement is made on the matching path. No history of previous transformations is saved. If rule is a function, it takes one argument path and must return a string representing the transformed path.


A collection of options for this rule. Supported options are:

  • weight: Assign a weight to this rule. Larger numbered rules run first.
  • last: A boolean that, if true, will prevent further rules from running.

The family of rules Inject supports:

comments powered by Disqus