Specs and fixes for nested partials with relative paths problem #28
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes "File to import not found or unreadable" problem when there are several load paths, and imported partials use relative paths:
#27
I believe
context.root_path
is to blame:https://github.com/petebrowne/sprockets-sass/blob/master/lib/sprockets/sass/importer.rb#L100
https://github.com/petebrowne/sprockets-sass/blob/master/lib/sprockets/sass/importer.rb#L63
There a two problems with that.
For example, a file A in
assets/
imports a file B fromvendor/
. Now, if any @import directive in file B uses relative path, you would want to build this relative path fromvendor/
, butcontext.root_path
points toassets/
.Sprockets::Context#resolve()
treats relative paths starting with '.' or '..' as if they originated fromcontext.pathname.dirname
which is the actual directory where file A resides, not fromcontext.root_path
.https://github.com/sstephenson/sprockets/blob/master/lib/sprockets/context.rb#L78
Current sprockets-sass code builds relative paths from
context.root_path
, which in case of file A inassets/
and file B invendor/
come in form../vendor/
. This works only whencontext.pathname.dirname
andcontext.root_path
are the same. I.e. if file A is at the topmost level inassets/
. Placing it somewhere deeper, like inassets/folder/
, breaks things.My patch fixes these problems by finding appropriate root_path, so a relative path built from it is resolved properly by
Sprockets::Context#resolve()
.