-
Notifications
You must be signed in to change notification settings - Fork 339
enhanced source path resolution for useminPrepare #306
Conversation
…tead of joining path themselves
…th, root (which can be an array), and then file.searchPath
…resolve a source reference in a block.
… rules for resolving source urls.
this is actually very very useful , especially when working with django |
Thanks! I'm in a similar boat with a pyramid project that has some rather complex URL mappings. I'm crossing my fingers that this gets accepted eventually, or something with equal flexibility. Until then, let me know if you run into any bugs in the patch (assuming you're actively using the fork :) |
I've updated my fork to include the all changes merged into usemin since I made this pull request. I'd really love if these features could make it into usemin, as I'm relying on them in production already :) If someone could let me know if there's anything I can do to make this patch more acceptable, or if there are parts which need explanation? |
@eli-collins this is really waiting on #313 (comment) If you or anyone you know would be interested let us know. I currently don't have time or enough grasp of the codebase to handle this. |
@HiroAgustin This PR is quite old now. Maybe it should be splitted into differents parts. |
closing it in favor of #518 which is the same work rebased on master with some additions. |
Thanks @eli-collins ! |
Rebase on #306 and additions
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:
context
object now exposes acontext.resolveInFile(fname)
helper (provided by theConfigWriter
), which flow plugins should use to convert a filename to it's path(rather than using
path.join(context.inDir, fname)
). This single changeallows source resolution to be moved back into ConfigWriter, where a
number of new features have been added...
root
option can now be an array, which will be searched in order.(this is similar to PR useminPrepare accepts array of root directories #296, but the changes here are made to lib/configwriter,
rather than lib/config/concat, and should work for all plugins).
all the root dirs, and then all the file searchpath (this clears up
a few FIXMEs within the code).
warnMissing
option, which causes ConfigWriter to issue a warning/errorfor any source references it can't resolve (ala issue Warn on missing files #260). This defaults to off,
so as not to break things for people.
resolveSource()
option, which allows applicationsto completely override how source urls are resolved... this allows handling of
applications with complex url rewrite rules, runtime template insertions
within the source url, or any other border case not covered by the default behavior.
I'm still testing this on my own projects, and given that I'm not familiarwith 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.
edit: All of these features should now have unittests.