-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
67 lines (58 loc) · 1.98 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
65
66
var gulp = require('gulp');
var less = require('gulp-less');
var autoprefixer = require('gulp-autoprefixer');
var consolidate = require('gulp-consolidate');
var iconfont = require('gulp-iconfont');
gulp.task('compile-less', function() {
gulp.src('src/assets/less/site.less')
.pipe(less())
.pipe(gulp.dest('src/assets/css/'));
});
gulp.task('watch-less', function() {
gulp.watch('src/assets/less/**/*.less' , ['compile-less']);
});
//Convert SVG to font icon
gulp.task('iconfont', function () {
return gulp.src('src/assets/images/icons/*.svg')
.pipe(iconfont({
fontName: 'ic',
formats: ['ttf', 'eot', 'woff', 'woff2'],
appendCodepoints: true,
appendUnicode: false,
normalize: true,
fontHeight: 1000,
centerHorizontally: true
}))
.on('glyphs', function (glyphs, options) {
gulp.src('src/assets/icon-font/*.less')
.pipe(consolidate('underscore', {
glyphs: glyphs,
fontName: options.fontName,
fontDate: new Date().getTime()
}))
.pipe(gulp.dest('src/assets/icon-font/dist/less'));
gulp.src('src/assets/icon-font/index.html')
.pipe(consolidate('underscore', {
glyphs: glyphs,
fontName: options.fontName
}))
.pipe(gulp.dest('src/assets/icon-font/dist/'));
})
.pipe(gulp.dest('src/assets/icon-font/dist/fonts'));
});
//Copy JS files from src/assets/vendor to
gulp.task('copyfiles', function() {
gulp.src('src/assets/icon-font/dist/fonts/*.{ttf,woff,woff2,eot,svg}')
.pipe(gulp.dest('src/assets/fonts/icon-font'));
});
gulp.task('autoprefixer', function () {
return gulp.src('src/assets/css/site.css')
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(gulp.dest('src/assets/css'));
});
gulp.task('font', ['iconfont']);
gulp.task('less', ['compile-less', 'copyfiles']);
gulp.task('default', ['compile-less', 'copyfiles', 'watch-less']);