-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathfonts.js
36 lines (30 loc) · 905 Bytes
/
fonts.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
'use strict';
/**
* @function `gulp css:fonts`
* @desc Encode *.otf or *.ttf or *.woff fonts to base64 data
*/
var gulp = require('gulp');
var taskName = 'css:fonts',
taskConfig = {
src: ['./source/assets/fonts/**/*.otf', './source/assets/fonts/**/*.ttf', './source/assets/fonts/**/*.woff'],
dest: './source/assets/.tmp/',
fileName: 'fonts.css'
};
gulp.task(taskName, function() {
var font64 = require('gulp-simplefont64'),
concat = require('gulp-concat'),
cssMinify = require('gulp-minify-css'),
tap = require('gulp-tap');
return gulp.src(taskConfig.src)
.pipe(font64())
.pipe(concat(taskConfig.fileName))
.pipe(cssMinify())
.pipe(tap(function(file) {
file.contents = Buffer.from(file.contents.toString().replace(/\; base64/g, ';charset=utf-8;base64'));
}))
.pipe(gulp.dest(taskConfig.dest));
});
module.exports = {
taskName: taskName,
taskConfig: taskConfig
};