2createStudio / postcss-sprites

Generate sprites from stylesheets.
MIT License
413 stars 50 forks source link

How to use within Grunt? #17

Closed pauleustice closed 9 years ago

pauleustice commented 9 years ago

Hey. I'm attempting to use this plugin within Grunt but keep getting the "no exist" error, and I'm not clear on whether the values for stylesheetPath and spritePath should be relative to the gruntfile, the postcss file being processed, or the output css file.

At present I am referencing the images relatively, so I'm confused as to why they're not found.

Dir structure:

css/ (output directory)
images/
  - sprite/
      spriteImage1.png
      spriteImage2.png
pcss/
  - subfolder/
      spriteStuff.pcss
  main.pcss (includes subfolder/spriteStuff.pcss)
gruntfile.js

And the line within spriteStuff.pcss:

background: url('../../images/sprite/spriteImage1.png');

Any tips as to what's up with this? Thanks!

pauleustice commented 9 years ago

For anyone else experiencing the same issue, if using from within an @import-ed file, the paths within your CSS must be relative from the top level file that you're processing (e.g. the one you define as your src file in grunt).