File: gulpfile.js

package info (click to toggle)
inkscape-open-symbols 1.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 10,112 kB
  • sloc: python: 22; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 1,370 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var gulp = require('gulp');
var svgSymbols = require('gulp-svg-symbols');
var util = require('gulp-util');
var cheerio = require('gulp-cheerio');
var rename = require("gulp-rename");

if (util.env.dest && util.env.iconset ) {
    var dist = util.env.dest + '/' + util.env.iconset + '/sprite';
} else {
    var err = new Error( 'parameter "--iconset" and "--dest" folder required ');
    throw err;
}

gulp.task('sprites', function () {
  return gulp.src('**/' + util.env.iconset + '/*.svg')
    .pipe(cheerio({
        run: function ($) {
            $('[fill]').removeAttr('fill');
            $('[stroke]').removeAttr('stroke');
            $('[stroke-width]').removeAttr('stroke-width');
            $('[stroke-width]').removeAttr('stroke-width');
            $('[fill-rule]').removeAttr('fill-rule');
            $('[stroke-width]').removeAttr('stroke-width');
            $('[stroke-linecap]').removeAttr('stroke-linecap');
            $('[stroke-linejoin]').removeAttr('stroke-linejoin');
            $('[height]').removeAttr('height');
            $('[width]').removeAttr('width');
            $('[style]').removeAttr('style');
        },
        parserOptions: { xmlMode: true }
    }))
    .pipe(svgSymbols({
        title: '%f'
    }))
    // .pipe(rename(util.env.iconset + '-symbols.svg'))
    .pipe(gulp.dest(dist));
});

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