Skip to content

Instantly share code, notes, and snippets.

@PaulMorel
Created June 20, 2018 14:17
Show Gist options
  • Save PaulMorel/dfe29b903f26d4bc3125bd9c001f666e to your computer and use it in GitHub Desktop.
Save PaulMorel/dfe29b903f26d4bc3125bd9c001f666e to your computer and use it in GitHub Desktop.
Gulp SVG Sprite
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/'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment