2createStudio / postcss-sprites

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

Sprite sheets are no longer generated after v2.0.2 #34

Closed jednano closed 8 years ago

jednano commented 8 years ago

I'm certain that the offending PR is https://github.com/2createStudio/postcss-sprites/pull/25. I've already made a comment there.

Here is my input CSS:

/* styles/sheets/foo/index.css */
@import baz;

/** styles/blocks/baz.css */
.icon {
    background: url('../sheets/foo/images/bar.png');
}

I logged some info to the console around line 138.

Before (v2.0.1):

styleFilePath: Z:\project\styles\sheets\foo\index.css
   image.path: Z:\project\styles\sheets\foo\images\bar.png

After (v2.0.2):

styleFilePath: Z:\project\styles\blocks\baz.css
   image.path: Z:\project\styles\blocks\images\bar.png

And here is my configuration:

{
    stylesheetPath: 'build/public/css',
    spritePath: '../public/images/sprites/sprite.png',
    groupBy: image => {
        const group = image.path.split(sep).slice(-3, -2)[0];
        if (image.retina) {
            return `${group}@${image.ratio}x`;
        }
        return group;
    },
    skipPrefix: true,
    outputDimensions: true,
    padding: 10,
    verbose: true,
    retina: true
}

Any ideas how to fix this? I've tried to be as thorough as possible here.

jednano commented 8 years ago

I think I can agree that it's better the new way, but the problem is that it introduces a breaking change and I was relying on the "bug" we had before.

jednano commented 8 years ago

Still, the image URL that's provided is relative to the css.source.input.file, not the rule.source.input.file. Are we sure this "fix" was really fixing anything?

vvasilev- commented 8 years ago

Thanks for your feedback. PR #25 was reverted to workaround the bug with paths.