2

I have a compass project set up in a sub-directory (/project/sub1/sub2/sub3/sub4/). The SCSS files are located at /project/sub1/sub2/sub3/sub4/css/src and images are at /project/sub1/sub2/sub3/sub4/images.

I need to generate a sprite whose source PNGs are saved in a directory outside of the project (/project/sub1/sub2/sub3/alternate-sub4/images/global). I tried changing the path around for my @import, but it keeps throwing an error when compiling my SCSS that says "no files were found in the load path..".

Here is my @import in _sprites.scss:

@import "/../../../alternate-sub4/images/global/*.png";

My config.rb is located at /project/sub1/sub2/sub3/sub4/

http_path = "/"
css_dir = "css"
sass_dir = "css/src"
images_dir = "images"
javascripts_dir = "js"
fonts_dir = "fonts"

Can somebody tell me what I need to change to get this to work? I have tried many different things including symbolic links and pointing to the directory using sprite_load_path, but nothing seems to work.

4
  • have you tried the full path? Jun 19, 2013 at 17:59
  • Yes, that's the only thing that I could get to work, however it needs to work for other devs, so it has to be relative to the project directory.
    – Stevo
    Jun 19, 2013 at 19:52
  • Have you tried symbolic links? Jun 20, 2013 at 7:07
  • I think your paths should be something like css_dir = "~/css/" OR "/css/" Jun 26, 2013 at 12:43

1 Answer 1

3

You can add an additional path where Compass will look for sprites, using the following configuration:

sprite_load_path << '../alternate-sub4/images'

or

sprite_load_path << File.expand_path('../alternate-sub4/images')

And in your SCSS file, import the PNGs files:

@import 'global/*.png';

See the configuration reference.

Note:
The sprite_load_path directive is an Array which is why the addition of a path is made using the Ruby operator <<.

2
  • I had added this line "sprite_load_path = "/Volumes/Macintosh \HD/Sites/project/sub1/sub2/sub3/alternate-sub4/images/" " to my config.rb file, but I can only get it to work if the full-path is defined. Any ideas how to make it so it's relative to the project directory? I tried "../", but no dice. :(
    – Stevo
    Jun 21, 2013 at 18:43
  • @user2113311 Oops, I badly written the additional path. Note that the sprite_load_path directive is an Array which is why the addition of a path is made using the Ruby operator <<.
    – piouPiouM
    Jun 22, 2013 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.