forked from DeFiCh/defichain.com
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
48 lines (43 loc) · 1.28 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
40
41
42
43
44
45
46
47
48
var gulp = require('gulp');
var svgstore = require('gulp-svgstore');
var svgmin = require('gulp-svgmin');
var rename = require('gulp-rename');
var cheerio = require('gulp-cheerio');
var inject = require('gulp-inject');
var path = require('path');
gulp.task('svgstore', function () {
var svgs = gulp
.src('static/svg/icons/src/*.svg')
.pipe(svgmin(function (file) {
var prefix = path.basename(file.relative, path.extname(file.relative));
return {
plugins: [{
convertPathData: false
}, {
cleanupIDs: {
prefix: prefix + '-',
minify: true
}
}]
}
}))
.pipe(cheerio(function ($, file) {
$('[fill]').attr('fill', 'currentColor');
}))
.pipe(svgstore({ inlineSvg: true }))
.pipe(gulp.dest('dest'));
function fileContents(filePath, file) {
return file.contents.toString();
}
return gulp
.src('layouts/partials/src/inline-svg.html')
.pipe(inject(svgs, { transform: fileContents }))
.pipe(gulp.dest('layouts/partials'));
});
// Watch asset folder for changes
gulp.task("watch", function () {
var watcher = gulp.watch("static/svg/icons/src/**/*")
watcher.on('all', gulp.series('svgstore'))
})
// Set watch as default task
gulp.task("default", gulp.series("watch"))