-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.mjs
80 lines (70 loc) · 2.07 KB
/
gulpfile.mjs
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
import gulp from 'gulp';
const { src, series, dest, parallel, watch, task } = gulp;
import jshint from 'gulp-jshint';
import concat from 'gulp-concat';
import uglify from 'gulp-uglify';
import rename from 'gulp-rename';
import rimraf from 'gulp-rimraf';
import header from 'gulp-header';
import resume from 'gulp-resume';
import imagemin from 'gulp-imagemin';
const paths = {
JS: [
'Gulpfile.js',
'assets/js/vendor/jquery-1.9.1.min.js',
'assets/js/vendor/modernizr-2.7.1.custom.min.js',
'assets/js/plugins/jquery.fitvids.js',
'assets/js/plugins/jquery.magnific-popup.js',
'assets/js/plugins/responsive-nav.js',
'assets/js/plugins/simpleJekyllSearch.js',
'assets/js/_main.js',
'assets/js/_redirects.js',
]
};
function lint(cb) {
return src('assets/js/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
}
function clean(cb) {
return src(['assets/js/scripts*.js', 'resume.html'], {read: false, allowEmpty: true})
.pipe(rimraf());
}
function scripts(cb) {
return src(paths.JS.slice(1))
.pipe(concat('scripts.js'))
.pipe(dest('assets/js'))
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(dest('assets/js'));
}
function images(cb) {
return src('assets/images/**/*.{png,jpg,jpeg}')
.pipe(imagemin({
optimizationLevel: 7,
progressive: true
}))
.pipe(dest('assets/images'));
}
function buildResume() {
return src('resume.json')
.pipe(resume({
format: 'html',
theme: 'elegant'
}))
.pipe(header('---\n---\n'))
.pipe(rename('resume.html'))
.pipe(dest('.'));
}
function startWatch() {
watch(paths.JS, parallel(lint, scripts));
watch('resume.json', buildResume);
}
task('default', series(clean, parallel(lint, scripts, images, buildResume)));
task('prod', parallel(
lint, scripts, images,
// buildResume
));
task('dev', series(clean, parallel(lint, scripts, images, buildResume), startWatch));