svg-sprite / grunt-svg-sprite

SVG sprites & stacks galore — Grunt 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

Home Page:https://github.com/svg-sprite/svg-sprite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Changing created directory's

myurtsev opened this issue · comments

Hi,

Is there an option to prevend the creation of the 'view' and 'svg' directory? Right now it is automaticly saved in 'view/svg/sprite.view.svg' I just want the sprite.view.svg placed in the dest directory.

Another question :) Can I name it to?

Basically I want to name and save the created sprite and css where I want to. Hope you can help.

Thanks!

Hello @myurtsev,

Check this out:

example: {
       expand: true,
        cwd: '<%= yeoman.app %>/images/example/design/sprites-vector',
        src: ['**/*.svg'],
        dest: '<%= yeoman.app %>/',
        options: {
            mode: {
                css: {
                    prefix: '%example-%s',
                    dest: 'styles/example', //scss destination
                    sprite: '../../images/example/design/example-sprite.svg', //Sprite destination and name
                    bust: false,
                    render: {
                        scss: {
                            dest: '_example-sprite.scss' //scss name
                        }
                    }
                }
            }
        }
   }

Thanks for helping out, @PeterMK85! :)

@myurtsev: Yes, there are config options for all of these. Basically, you need to set the main output directory dest, the mode output directory mode.view.dest and the sprite path and name mode.view.sprite accordingly. In your case, you will probably want something like tthis:

var config = {
     dest: 'your/output/dir',
     mode: {
          view: {
               dest: '.',
               sprite: 'whatever-you-want.svg'
          }
     }
}

Thank you @jkphl and @PeterMK85 really helpfull! But is it also possible to change the background position in pixels instead of percentages.

Yes, you can always author your own Mustache template and use the absolute position values instead. However, switching to relative positioning (and thus making the positioning responsive) was one of the major improvements of the new svg-sprite generation. Why would you want absolute positioning?