-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
124 lines (114 loc) · 3.48 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
var gulp = require('gulp'),
cp = require('child_process'),
browserSync = require('browser-sync'),
sass = require('gulp-sass'),
prefix = require('gulp-autoprefixer'),
gutil = require('gulp-util'),
plumber = require('gulp-plumber'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
iconfont = require('gulp-iconfont'),
iconfontCss = require('gulp-iconfont-css'),
sassUnicode = require('gulp-sass-unicode');
// gulp jekyll-build
gulp.task('jekyll-build', ['js-min'], function (done) {
browserSync.notify('gulp jekyll-build');
var jekyll = process.platform === "win32" ? "jekyll.bat" : "jekyll";
return cp.spawn(jekyll, ['build', '--config', '_config.yml,_config_dev.yml'], {stdio: 'inherit'})
.on('close', done);
});
// gulp jekyll-rebuild
gulp.task('jekyll-rebuild', ['jekyll-build'], function () {
browserSync.reload();
});
// gulp browser-sync
gulp.task('browser-sync', ['sass'], function() {
browserSync({
server: {
baseDir: '_site'
}
});
});
// gulp sass
gulp.task('sass', function () {
return gulp.src([
'_scss/main.scss'
])
.pipe(plumber(function(error) {
gutil.log(gutil.colors.red(error.message));
this.emit('end');
}))
.pipe(sass({
includePaths: ['scss'],
outputStyle: 'compressed'
}))
.pipe(sassUnicode())
.pipe(prefix(['last 2 versions', 'ie 8', 'ie 9'], { cascade: true }))
.pipe(gulp.dest('_site/assets/css/'))
.pipe(browserSync.reload({stream: true}))
.pipe(gulp.dest('assets/css/'));
});
// gulp js-concat
gulp.task('js-concat', function() {
return gulp.src([
'_js/lib/*',
'_js/vendor/*',
'_js/main.js',
'_components/**/*.js',
])
.pipe(concat('all.js'))
.pipe(gulp.dest('assets/js/'));
});
// gulp js-min
gulp.task('js-min', ['js-concat'], function() {
return gulp.src(['assets/js/all.js'])
.pipe(plumber(function(error) {
gutil.log(gutil.colors.red(error.message));
this.emit('end');
}))
.pipe(uglify())
.pipe(concat('all.min.js'))
.pipe(gulp.dest('assets/js/'));
});
// gulp font
gulp.task('font', function () {
var fontName = 'svg-font';
return gulp.src('assets/img/svg-icons/*.svg')
.pipe(iconfontCss({
fontName: fontName,
path: '_scss/vendor/svg-icons/_template.scss',
targetPath: '../../_scss/vendor/svg-icons/_font.scss',
fontPath: './../fonts/'
}))
.pipe(iconfont({
fontName: fontName,
fontHeight : 1001,
formats: ['svg', 'ttf', 'eot', 'woff', 'woff2'],
normalize: true
}))
.pipe(gulp.dest('_site/assets/fonts/'))
.pipe(browserSync.reload({stream:true}))
.pipe(gulp.dest('assets/fonts/'));
});
// gulp watch
gulp.task('watch', ['js-min', 'browser-sync'], function () {
gulp.watch([
'_scss/**/*',
'_components/**/*.scss',
], ['sass']);
gulp.watch([
'_layouts/**/*',
'_components/**/*.html',
'_components/**/*.js',
'_components/**/*.yml',
'_components/**/*.json',
'_js/**/*',
'_pages/**/*',
'_posts/**/*',
'assets/img/**/*',
'assets/fonts/**/*',
'_config_dev.yml'
], ['jekyll-rebuild']);
});
// gulp
gulp.task('default', ['sass', 'jekyll-build']);