svg-sprite / gulp-svg-sprite

SVG sprites & stacks galore — Gulp plugin wrapping around svg-sprite that reads in a bunch of SVG files, optimizes them and creates SVG sprites and CSS resources in various flavours
MIT License
647 stars 43 forks source link

Stylus path problem #6

Closed tiagoporto closed 9 years ago

tiagoporto commented 9 years ago

Hello, i have the follow task in my gulpfile.js

gulp.task('svg-sprite', function() {
    gulp.src('src/images/svg-sprite/*.svg')
        .pipe(plumber())
        .pipe(svgSprite({
            mode : {
                css : {
                    dest : './',
                    sprite: '../images/svg-sprite.svg',
                    bust : false,
                    render : {
                        styl : {dest: '../../src/stylesheets/helpers/_svg-sprite.styl'}
                    }
                }
            }
        }))
        .pipe(gulp.dest('./public/images/'));
});

Works fine, the files are going to the right folders, and my .styl file generate this.

$svg-common 
    background-repeat no-repeat
    background-image url(..\images\svg-sprite.svg)

In the background-image the path is generated with backslash, when the stylus is compiled I have a problem, because they ignore the first backslash.

background-image: url("..imagessvg-sprite.svg");

Can someone help?

jkphl commented 9 years ago

Hey @tiagoporto,

thanks for reporting this. First of all, I assume you are on Windows, right? (Otherwise I'd wonder where the backslashes would come from ...). I must admit that I didn't test on Windows too thoroughly yet and that I'm not really familiar with Stylus at all, but maybe we can get that going without all this ...

Could you please try compiling the Stylus file and manually change the backslashes to regular slashes before. Does this work? I doubt the backslash is valid in this situation ... I'd then go and let svg-sprite consequently replace the backslashes.

Also, I remember there has been another similar issue once. I'll try to find it ...

Cheers, Joschi

jkphl commented 9 years ago

No, sorry, I mixed things. What I had in mind is the escape function that is part of the templating variables, but that serves a different purpose. I guess I'll have to replace backslashes in file paths altogether. Can you please confirm this?

tiagoporto commented 9 years ago

Hello @jkphl, you are right. I am on windows 8.1. When I change manually '\' to '/', the stylus file is compiled perfectly. In stylus the backslash is used for Char Escaping.

jkphl commented 9 years ago

Ok, thanks. Just what I thought. I'll try to push out a fix later today or tomorrow.

jkphl commented 9 years ago

Should be fixed with release v1.0.13. Please let me know if this works for you (just did a very rough test on Windows today). I'll close the issue for now, but please feel free to re-open if you still have trouble with it.

tiagoporto commented 9 years ago

Problem solved. Thanks.