-
Notifications
You must be signed in to change notification settings - Fork 95
/
gulpfile.js
39 lines (36 loc) · 1.33 KB
/
gulpfile.js
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;
}
function sprites () {
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', gulp.series(sprites));