-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
65 lines (59 loc) · 2.01 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var gulp = require('gulp');
var fs = exports.fs = require('fs');
var iconfont = require('gulp-iconfont');
var iconfontCss = require('gulp-iconfont-css');
var template = require('gulp-template');
var fontName = 'devui-icomoon';
var devUIFontDir = './icomoon/';
var runTimestamp = Math.round(Date.now() / 1000);
gulp.task('iconfont', function (done) {
gulp.src(devUIFontDir + 'svg/**/*.svg')
.pipe(iconfontCss({
fontName: fontName,
path: './templates/_icon.less',
targetPath: '../devui-icon.css',
cssClass: 'icon',
fontPath: 'fonts/',
centerHorizontally: true,
cacheBuster: runTimestamp,
}))
.pipe(iconfont({
fontName: fontName,
formats: [ 'svg','ttf', 'eot', 'woff'],
normalize: true,
fontHeight:1001,
cacheBuster: runTimestamp,
})).on('glyphs', function(glyphs, options) {
console.log(glyphs, options);
})
.pipe(gulp.dest( './icomoon/fonts'));
done();
});
function getIcons(dir) {
let opIcons = [];
if(fs.existsSync("./" + dir)) {
opIconsTmp = fs.readdirSync("./" + dir);
opIconsTmp.map(function (icon) {
if(icon.endsWith(".svg") ) {
opIcons.push(icon.replace(/\.\w+$/, ''));
}
});
}
console.log(opIcons);
return opIcons;
}
gulp.task('demo', function (done) {
gulp.src(`./templates/index.html`)
.pipe(template({
meanIcons: getIcons("icomoon/svg/mean"),
opIcons: getIcons("icomoon/svg/op"),
statusIcons: getIcons("icomoon/svg/status"),
commonIcons: getIcons("icomoon/svg/mean/common"),
otherIcons: getIcons("icomoon/svg/mean/other"),
editorIcons: getIcons("icomoon/svg/editor"),
codeEditorIcons: getIcons("icomoon/svg/code-editor"),
cssName: 'devui-icon',
}))
.pipe(gulp.dest("."));
done();
});