Skip to content

chengsong-cs/svg2symbol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status npm

svg2symbol

transfrom SVG file to symbol file

usage

recommend use with gulp-svgmin to optimize svg

notice: if you want to know why i write a lot of config code for svgmin plugin, please look at this issue

var gulp = require('gulp');
var svg2symbol = require('./index');
var svgmin = require('gulp-svgmin');
var path = require('path');

gulp.task('svg', function () {
    return gulp
        .src('./test/*.svg')
        .pipe(svgmin({
            full: true,
            plugins: [
                "removeDoctype",
                "removeXMLProcInst",
                "removeComments",
                "removeMetadata",
                {
                    removeXMLNS: true
                },
                "removeEditorsNSData",
                "cleanupAttrs",
                "minifyStyles",
                "convertStyleToAttrs",
                "cleanupIDs",
                {
                    removeRasterImages: true
                },
                "removeUselessDefs",
                "cleanupNumericValues",
                "cleanupListOfValues",
                "convertColors",
                "removeUnknownsAndDefaults",
                "removeNonInheritableGroupAttrs",
                "removeUselessStrokeAndFill",
                "cleanupEnableBackground",
                "removeHiddenElems",
                "removeEmptyText",
                "convertShapeToPath",
                "moveElemsAttrsToGroup",
                "moveGroupAttrsToElems",
                "collapseGroups",
                "convertPathData",
                "convertTransform",
                "removeEmptyAttrs",
                "removeEmptyContainers",
                "mergePaths",
                "removeUnusedNS",
                {
                    sortAttrs: true
                },
                {
                    removeTitle: true
                },
                "removeDesc",
                "removeDimensions",
                // "removeElementsByAttr",
                // "addClassesToSVGElement",
                {
                    removeStyleElement: true
                },
                // "addAttributesToSVGElement",
                {
                    transformsWithOnePath: {
                        width: 24,
                        height: 24
                    }
                },
                {
                    removeAttrs: ['style', 'fill', 'opacity']
                }
            ]
        }))
        .pipe(svg2symbol())
        .pipe(gulp.dest('res'));
});

gulp.task('default', ['svg']);

About

transfrom SVG file to symbol file

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published