forked from Code-Pop/open-sourcecraft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
32 lines (30 loc) · 834 Bytes
/
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
var gulp = require('gulp');
var path = require('path');
var inject = require('gulp-inject');
var svgmin = require('gulp-svgmin');
var cheerio = require('gulp-cheerio');
var svgstore = require('gulp-svgstore');
gulp.task('default', function(){
return gulp
.src('images/icons/*.svg')
.pipe(svgmin(function(file) {
var prefix = path.basename(file.relative, path.extname(file.relative));
return {
plugins: [{
cleanupIDs: {
prefix: prefix + '-',
minify: true
}
}]
}
}))
.pipe(cheerio({
run: function ($) {
$('[fill]').removeAttr('fill');
$('[stroke]').removeAttr('stroke');
},
parserOptions: { xmlMode: true }
}))
.pipe(svgstore({ inlineSvg: true, cleanup: true}))
.pipe(gulp.dest('_includes'))
});