Hiswe / gulp-cheerio-clean-svg

presets for gulp-cheerio
3 stars 0 forks source link

don't remove class #1

Open seriiserii825 opened 5 years ago

seriiserii825 commented 5 years ago

I ask this question at this forum https://toster.ru/q/611108 The initial svg is `<?xml version="1.0" encoding="utf-8"?>

<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 48 48" style="enable-background:new 0 0 48 48;" xml:space="preserve">

`

the svg code in gulp gulp.task('svg', function () { return gulp.src('src/assets/i/svg/inline/*.svg', {since: gulp.lastRun('svg')}) .pipe(gp.newer('build/assets/i/svg/sprite/')) .pipe(gp.svgmin({ js2svg: { pretty: true } })) .pipe(gp.cheerio(clean( { removeSketchType: true, removeEmptyGroup: true, removeEmptyDefs: true, removeEmptyLines: true, removeComments: true, tags: [ 'title', 'desc', ], attributes: [ 'style', 'fill*', 'stroke*', ], } ))) .pipe(gp.replace('&gt;', '>')) .pipe(gp.svgSprite({ mode: { symbol: { sprite: "../sprite.svg", } } })) .pipe(gulp.dest("build/assets/i/svg/inline/")); });

and the result <symbol viewBox="0 0 48 48" id="crop" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h48v48H0V0z"/><path d="M36.4 29.6h4v-16c0-2.2-1.8-4-4-4h-16v4h16v16zm-20 4v-32h-4v8h-8v4h8v20c0 2.2 1.8 4 4 4h20v8h4v-8h8v-4h-32z"/></symbol>

How to say gulp-cherrio-clean-svg to not remove attribute class?

Hiswe commented 5 years ago

@seriiserii825 I don't think this come from the clean function. Have you checked svgmin or svgSprite?