Skip to content

Instantly share code, notes, and snippets.

@PaulMorel
Created June 20, 2018 14:17
  • Select an option

Select an option

Revisions

  1. PaulMorel created this gist Jun 20, 2018.
    50 changes: 50 additions & 0 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    var config = {
    basePath: {
    src: 'assets/',
    }
    };

    var svgsprite = require('gulp-svg-sprite');

    function sprite() {
    return gulp.src(
    config.basePath.src + 'img/sprites/*.svg'
    )
    .pipe(plumber({
    errorHandler: onError
    }))
    .pipe(svgsprite({
    log: 'info',
    shape: {
    id: {
    whitespace: '-'
    },
    dimension: {
    precision: 0,
    attributes: true
    },
    transform: [{
    custom: function (shape, sprite, callback) {
    callback(null);
    }
    }]
    },
    svg: {
    xmlDeclaration: true,
    doctypeDeclaration: true,
    precision: 1,
    namespaceClassnames: false,
    dimensionAttributes : true
    },
    mode: {
    symbol: {
    dest: './',
    bust: false,
    prefix: '.sprite-%s',
    sprite: '../img/sprite.svg',
    inline: true
    }
    }
    }))
    .pipe(gulp.dest(config.basePath.src + 'img/'));
    }