Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Gulpfile for SVG symbols building
var gulp = require('gulp')
//,replace = require('gulp-replace')
,rename = require('gulp-rename')
,svgstore = require('gulp-svgstore')
,svgmin = require('gulp-svgmin')
;
gulp.task('default', function() {
gulp.src(['svg_files/*.svg'])
.pipe(rename(function (path) {
path.basename = path.basename.replace(/icon_prefix_/, '');
return path;
}))
.pipe(svgmin(function (file) {
return {
// https://github.com/svg/svgo/tree/master/plugins
plugins: [
{ cleanupIDs: { remove: true, minify: true } }
, { removeDoctype: true }
, { removeComments: true }
, { removeStyleElement: true }
, { removeDimensions: true }
, { cleanupNumericValues: { floatPrecision: 2 } }
, { convertColors: { names2hex: true, rgb2hex: true } }
, { removeAttrs: { attrs: ['(fill|stroke|class|style)', 'svg:(width|height)'] } }
]
//,js2svg: { pretty: true }
};
}))
.pipe(svgstore())
//.pipe( replace(/<style>(.*?)<\/style>/g, '') )
.pipe( rename('my-icons.svg') )
.pipe(gulp.dest('./'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.