-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathgulpfile.js
108 lines (93 loc) · 3.04 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
const { series, parallel, src, dest, watch } = require('gulp');
const concat = require('gulp-concat');
const compiler = require('gulp-closure-compiler');
const cleancss = require('gulp-clean-css');
const gulpif = require('gulp-if');
const del = require('del');
let prod = true;
function cleanTask() {
return del([
'assets/js/*.js',
'assets/css/*.css',
'assets/font/*',
])
}
function jsLibTask() {
return src(['src/js/vendor/jquery.min.js', 'src/js/vendor/materialize.min.js',
'src/js/vendor/prettydate.js', 'src/js/vendor/prettydate.zh-CN.min.js',
'src/js/vendor/uuid.js', 'src/js/vendor/md5.min.js', 'src/js/vendor/js.cookie.min.js',
'src/js/vendor/cache.js', 'src/js/vendor/prism.js', 'src/js/vendor/highlight.min.js',
'src/js/vendor/linkify.min.js', 'src/js/vendor/linkify-jquery.min.js'])
.pipe(concat('lib.js'))
.pipe(dest('assets/js'))
}
function fontTask() {
return src('src/font/*')
.pipe(dest('assets/font/'))
}
function podcastResTask() {
return src('src/podlove/**/*')
.pipe(dest('assets/podlove/'))
}
function jsEchartsTask() {
return src('src/js/vendor/echarts.min.js')
.pipe(dest('assets/js'))
}
function jsPcTask() {
return src(['src/js/ohmyrss.js', 'src/js/pc.js', 'src/js/vimlike-shortcuts.js'])
.pipe(gulpif(prod === true, compiler({
compilerPath: './node_modules/google-closure-compiler/compiler.jar',
fileName: 'pc.js',
compilation_level: 'SIMPLE',
compilerFlags: {
language_in: 'ECMASCRIPT6',
language_out: 'ES5'
}
})))
.pipe(gulpif(prod === false ,concat('pc.js')))
.pipe(dest('assets/js'))
}
function jsMobileTask() {
return src(['src/js/ohmyrss.js', 'src/js/mobile.js'])
.pipe(gulpif(prod === true, compiler({
compilerPath: './node_modules/google-closure-compiler/compiler.jar',
fileName: 'mobile.js',
compilation_level: 'SIMPLE',
compilerFlags: {
language_in: 'ECMASCRIPT6',
language_out: 'ES5'
}
})))
.pipe(gulpif(prod === false ,concat('mobile.js')))
.pipe(dest('assets/js'))
}
function cssLibTask() {
return src('src/css/vendor/*.css')
.pipe(concat('lib.css'))
.pipe(cleancss())
.pipe(dest('assets/css'))
}
function cssPcTask() {
return src('src/css/pc.css')
.pipe(cleancss())
.pipe(dest('assets/css'))
}
function cssMobileTask() {
return src('src/css/mobile.css')
.pipe(cleancss())
.pipe(dest('assets/css'))
}
exports.build = series(
cleanTask,
jsEchartsTask, fontTask,
jsLibTask, cssLibTask,
parallel(cssMobileTask, cssPcTask),
parallel(jsPcTask, jsMobileTask),
podcastResTask,
);
exports.default = function() {
prod = false;
watch(['src/js/*.js'], parallel(jsPcTask, jsMobileTask));
watch(['src/css/*.css'], parallel(cssMobileTask, cssPcTask));
};
exports.clean = series(cleanTask)