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

How to format config to output sprite at root folder? #155

Closed
RoxKilly opened this issue May 10, 2016 · 2 comments
Closed

How to format config to output sprite at root folder? #155

RoxKilly opened this issue May 10, 2016 · 2 comments
Assignees
Labels

Comments

@RoxKilly
Copy link

RoxKilly commented May 10, 2016

gul-svg-sprite 1.2.19

I'm having a lot of trouble with the config object that is passed to gulp-svg-sprite to determine the destination of the file created. I have read the doc section on output destination and read through this StackOverflow board on the matter.

Here is the gulp task

gulp.task('build-icons',function(){
    return gulp.src(assetsDev+'icons/*.svg')
        .pipe(svgSprite({
            mode: {defs:true, dest:'.'},
        }))
        .pipe(gulp.dest('icons'));
});

This is what I'm hoping to get
icons/
---sprite.defs.svg

This is what I get instead
icons/
---defs/
------svg/
---------sprite.defs.svg

I've tried changing the value of mode.dest, or adding a dest setting as a sibling to mode but it makes no difference. Basically, no matter what I write, the file is always saved in the same location. I think my setting is just ignored. For instance if I add the option sprite:"mysprite.svg" within the mode settings, the file is still saved as "sprite.defs.svg" in the same location as above.

What am I missing? I bet it's really obvious.

@jkphl jkphl added the question label May 14, 2016
@jkphl jkphl self-assigned this May 14, 2016
@jkphl
Copy link
Collaborator

jkphl commented May 14, 2016

Hey @RoxKilly,

you're simply using an insufficient configuration. Your config object should look like this:

var config = {
    'mode': {
        'defs': {
            'dest': '.',
            'sprite': 'sprite.devs.svg'
        }
    }
};

So your whole task could look like this:

gulp.task('build-icons', function () {
    return gulp.src(assetsDev + 'icons/*.svg')
        .pipe(svgSprite({
            'mode': {
                'defs': {
                    'dest': '.',
                    'sprite': 'sprite.devs.svg'
                }
            }
        }))
        .pipe(gulp.dest('icons'));
});

You should end up with icons/sprite.defs.svg then.

Cheers, Joschi

@jkphl jkphl closed this as completed May 14, 2016
@RoxKilly
Copy link
Author

Thanks!!

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

No branches or pull requests

2 participants