yeoman/grunt-usemin — pull request #306 by eli-collins (2014-03-02 23:52:12+00:00)
Title: enhanced source path resolution for useminPrepare

This set of commits make a number of changes to how source urls are resolved,
with the hope of making things more flexible and handling some edge cases.
I tried to change things in a way which should be backwards-compatible
with existing third-party flow plugins, while providing a number of new features:

* the `context` object now exposes a `context.resolveInFile(fname)` helper,
which flow plugins should use to convert a filename to it's path
(rather than using `path.join(context.inDir, fname)`. This single change
allows source resolution to be moved back into ConfigWriter, where a
number of new features have been added...

* the `root` option can now be an array, which will be searched in order.
(this is similar to PR #296, but the changes here are made to lib/configwriter,
rather than lib/config/concat, and should work for all plugins).

* source urls are now resolved against the entire block searchpath,
all the root dirs, and then all the file searchpath (this clears up
a few FIXMEs within the code).

* I've added a `warnMissing` option, which causes ConfigWriter to issue a warning
for any source references it can't resolve (ala issue #260). This defaults to off,
so as not to break things for people.

* finally, I added a `resolveSource()` option, which allows applications
to completely override how source urls are resolved... allowing handling of
applications with complex url rewrite rules, or runtime template insertions
within the source url.

I'm still testing this on my own projects, and given that I'm not familiar
with Mocha, don't have any unittests for this features written yet...
but I'm willing to give it a try if there's interest in merging this PR.