-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
139 lines (113 loc) · 3.35 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var minifyCSS = require('gulp-minify-css');
var browserSync = require('browser-sync').create();
var mainBowerFiles = require('main-bower-files')
const { src, pipe, series, dest, task } = require('gulp');
function jade() {
return src('./source/index.jade')
.pipe($.data(function () {
var resume = require('./resume/resume.json');
var source = {
'resume': resume,
};
return source;
}))
.pipe($.jade())
.pipe(dest('./public/'))
.pipe(browserSync.stream())
}
task('jade', jade);
function scss() {
return src('./source/scss/**/*.scss')
.pipe($.sass().on('error', $.sass.logError))
.pipe(dest('./.tmp/css'))
.pipe(browserSync.stream())
}
task('scss', scss);
function browser(done) {
browserSync.init({
server: {
baseDir: "./public"
}
})
done();
}
task('browser', browser)
// gulp.task('deploy', function () {
// return gulp.src('./public/**/*')
// .pipe($.ghPages());
// });
// //先講檔案載入暫時的資料夾
function bower() {
return src(mainBowerFiles())
.pipe(dest('./.tmp/vendors'))
}
task('bower', bower)
// //然後做出合併
function venderjs() {
return src(['./.tmp/vendors/**/*.js', './source/js/**/*.js'])
.pipe($.order([
'jquery.js',
'tether.js',
'bootstrap.js',
'wow.js',
'particles.min.js'
]))
.pipe($.concat('all.js'))
.pipe($.uglify({
compress: {
drop_console: true //把console.log 削掉
}
}))
.pipe(dest('./public/js'))
.pipe(browserSync.stream())
}
task('venderjs', series(bower, venderjs))
function venderCSS() {
return src(['./.tmp/vendors/**/*.css', './.tmp/css/**/*.css'])
.pipe($.concat('all.css'))
.pipe(minifyCSS())
.pipe(dest('./public/css'))
.pipe(browserSync.stream())
}
task('venderCSS', series(bower, venderCSS))
function venderFONT() {
return src("./.tmp/vendors/fontawesome-webfont.*")
.pipe(dest('./public/fonts'))
}
task('venderFONT', series(bower, venderFONT))
// //刪除資料夾
function clean() {
return src(['./.tmp', './public', './.publish'], { read: false, allowEmpty: true })
.pipe($.clean())
}
task('clean', clean)
function cleantmp() {
return src(['./.tmp'], { read: false, allowEmpty: true })
.pipe($.clean())
.pipe(browserSync.stream())
}
task(cleantmp, series(venderjs, venderCSS, venderFONT, cleantmp))
function watch() {
watch(['./source/**/*.jade'], series(jade));
// watch(['./source/resume/*.json'], series(jade));
// watch(['./source/**/*.scss'], series(scss));
}
task('watch', watch);
task('dev', series(bower, jade, scss, venderjs, venderCSS, venderFONT, cleantmp,
function (done) {
browserSync.init({
server: {
baseDir: "./public",
reloadDebounce: 2000
}
})
gulp.watch(['./source/**/*.jade'], series(jade));
gulp.watch(['./source/resume/*.json'], series(jade));
gulp.watch(['./source/**/*.scss'], series(scss));
done();
}
)
);
task('default', series(bower, jade, scss, venderjs, venderCSS, venderFONT, cleantmp));