Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Support For Nested Mappings #193

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ayushya
Copy link

@ayushya ayushya commented May 19, 2016

This is an additional Feature, to support the relative paths generated after compiling scss through 'compass'.

This PR adds the opt-in feature which adds the nested mapping of the assets.

As of now, all the links to asset files which are mapped are searched in all the files to be busted[replace the old link to assets to new mapped hashed links]

For E.g.

<img src="assets/images/homepage/myProfile.img">

Will be mapped with

<img src="assets/images/homepage/myProfile.ah21as.img"> 

But for the case when we are dealing with relative paths, the links wouldn't be replaced.

For E.g.

<img src="../images/homepage/myProfile.img">

For the above case, there would be no change in the file as it could not find
"assets/images/homepage/myProfile.img" to be replaced by "assets/images/homepage/myProfile.ah21as.img"

To support the feature all we need is add the following option in gruntfile:

            nestedMappings: true,
            nestedMappingsPattern: [
                {
                    pattern: 'assets/images/',
                    splitAt: 'assets/'
                }
            ]

I have also updated the Readme file for instructions to use it.

@benhoIIand
Copy link
Owner

benhoIIand commented May 25, 2016

Hi @ayushya. I understand that this is a use case that could potentially crop up a few times, but my advice would be to not use relative paths for static assets - is there a reason for you using them over absolute paths from the root?

I'd always use this
<img src="/assets/images/homepage/myProfile.img">

over this
<img src="../images/homepage/myProfile.img">

@glhewett
Copy link

glhewett commented Nov 5, 2016

Hi @HollandBen, I used to think that we should always use absolute paths since I spent many years in a rails environment, but over the years I have see more and more single page apps support relative paths to assets to that the app can be deployed into any path. Specifically, one app that I work on has the ability to deploy to gh-pages on the forked repo so that new changes can be shared with the team easily. Would you consider merging this PR if updated and meets all of our other contribution requirements?

@glhewett
Copy link

glhewett commented Nov 5, 2016

Or merge a different PR that solves the same issue?

@richardhinkamp
Copy link
Contributor

#211 fixes the relative path issue too, different approach so it works for all relative paths without any config.

@glhewett
Copy link

Cool, I made that comment before your PR. Thanks for that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants