-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
146 lines (135 loc) · 5.54 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
140
141
142
143
144
145
146
var gulp = require('gulp');
var imagemin = require("gulp-imagemin");
var imageresize = require('gulp-image-resize');
var exec = require('child_process').exec;
var newer = require('gulp-newer');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var browserSync = require('browser-sync').create();
// image resizing variables
var imagexl = 2620;
var imagefull = 1920;
var imagehalf = 1024;
var imagequart = 600;
var imagethumb = 80;
var imageload = 20;
var jsFiles = [
'themes/akia/assets/js/vendor/jquery.2.2.3.min.js',
'themes/akia/assets/js/vendor/bootstrap-select/dist/js/bootstrap-select.js',
'themes/akia/assets/js/vendor/bootstrap/bootstrap.min.js',
'themes/akia/assets/js/vendor/masonry.pkgd.js',
'themes/akia/assets/js/vendor/Camera-master/scripts/jquery.mobile.customized.min.js',
'themes/akia/assets/js/vendor/Camera-master/scripts/jquery.easing.1.3.js',
'themes/akia/assets/js/vendor/Camera-master/scripts/camera.min.js',
'themes/akia/assets/js/vendor/bootstrap-mega-menu/js/menu.js',
'themes/akia/assets/js/vendor/WOW-master/dist/wow.min.js',
'themes/akia/assets/js/vendor/owl-carousel/owl.carousel.min.js',
'themes/akia/assets/js/vendor/jquery.appear.js',
'themes/akia/assets/js/vendor/jquery.countTo.js',
'themes/akia/assets/js/vendor/fancybox/dist/jquery.fancybox.min.js',
'themes/akia/assets/js/vendor/jquery.ripples-master/dist/jquery.ripples-min.js',
'themes/akia/assets/js/vendor/jquery.mixitup.min.js',
'themes/akia/assets/js/vendor/fancybox/dist/jquery.fancybox.min.js',
'themes/akia/assets/js/theme/theme.js',
// 'themes/akia/assets/js/vendor/instafeed.min.js',
// 'themes/akia/assets/js/vendor/lazyload.js',
// 'themes/akia/assets/js/vendor/jquery.sticky-sidebar.js',
'themes/akia/assets/js/main.js'
];
var contactJsFiles = [
'themes/akia/assets/js/vendor/jquery.2.2.3.min.js',
'themes/akia/assets/js/vendor/bootstrap-select/dist/js/bootstrap-select.js',
'themes/akia/assets/js/vendor/bootstrap/bootstrap.min.js',
'themes/akia/assets/js/vendor/Camera-master/scripts/jquery.mobile.customized.min.js',
'themes/akia/assets/js/vendor/Camera-master/scripts/jquery.easing.1.3.js',
'themes/akia/assets/js/vendor/Camera-master/scripts/camera.min.js',
'themes/akia/assets/js/vendor/bootstrap-mega-menu/js/menu.js',
'themes/akia/assets/js/vendor/WOW-master/dist/wow.min.js',
'themes/akia/assets/js/vendor/owl-carousel/owl.carousel.min.js',
'themes/akia/assets/js/vendor/jquery.appear.js',
'themes/akia/assets/js/vendor/jquery.countTo.js',
'themes/akia/assets/js/vendor/fancybox/dist/jquery.fancybox.min.js',
'themes/akia/assets/js/vendor/jquery.ripples-master/dist/jquery.ripples-min.js',
'themes/akia/assets/js/vendor/contact-form/validate.js',
'themes/akia/assets/js/vendor/contact-form/jquery.form.js',
'themes/akia/assets/js/vendor/gmaps.min.js',
'themes/akia/assets/js/theme/theme.js',
'themes/akia/assets/js/theme/map-script.js',
// 'themes/akia/assets/js/vendor/instafeed.min.js',
// 'themes/akia/assets/js/vendor/lazyload.js',
// 'themes/akia/assets/js/vendor/jquery.sticky-sidebar.js',
'themes/akia/assets/js/main.js'
];
var jsDest = 'themes/akia/static/js';
// resize and optimize images
function imageResize() {
return gulp.src("themes/akia/source-images/*.{jpg,png,jpeg,JPG,gif}")
.pipe(newer("themes/akia/static/img"))
.pipe(imagemin([
imagemin.gifsicle({interlaced: true}),
imagemin.mozjpeg({progressive: true}),
imagemin.optipng({optimizationLevel: 5})
]))
.pipe(imageresize({ width: imagexl}))
.pipe(gulp.dest("themes/akia/static/xl/img"))
.pipe(imageresize({ width: imagefull }))
.pipe(gulp.dest("themes/akia/static/img"))
.pipe(imageresize({ width: imagehalf }))
.pipe(gulp.dest("themes/akia/static/half/img"))
.pipe(imageresize({ width: imagequart }))
.pipe(gulp.dest("themes/akia/static/quart/img"))
.pipe(imageresize({ width: imagethumb }))
.pipe(gulp.dest("themes/akia/static/thumb/img"))
.pipe(imageresize({ width: imageload }))
.pipe(gulp.dest("themes/akia/static/load/img"));
};
// hugo production call
function hugo(cb) {
exec('hugo --cleanDestinationDir', (err, stdout, stderr) => {
console.log(stdout);
console.log(stderr);
cb(err);
});
};
function sassTask() {
return gulp.src('themes/akia/assets/scss/main.scss')
.pipe(sourcemaps.init())
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(rename('main.min.css'))
.pipe(sourcemaps.write('themes/akia/static/css'))
.pipe(gulp.dest('themes/akia/static/css'));
};
function scriptsNormal() {
return gulp.src(jsFiles)
// .pipe(sourcemaps.init())
.pipe(concat('main.min.js'))
.pipe(uglify())
// .pipe(sourcemaps.write(jsDest))
.pipe(gulp.dest(jsDest));
};
function scriptsContact() {
return gulp.src(contactJsFiles)
// .pipe(sourcemaps.init())
.pipe(concat('main-contact.min.js'))
.pipe(uglify())
// .pipe(sourcemaps.write(jsDest))
.pipe(gulp.dest(jsDest));
}
var scripts = gulp.parallel(scriptsNormal, scriptsContact);
// watching
function watch() {
// browserSync.init({
// proxy: "http://localhost:1313/"
// });
gulp.watch('themes/akia/source-images/*.{jpg,png,jpeg,gif,JPG}', imageResize );
gulp.watch('themes/akia/assets/scss/**/*.scss', sassTask);
gulp.watch('themes/akia/assets/js/**/*.js', scripts);
};
exports.watch = watch;
// watching images and resizing
exports.dev = gulp.series(imageResize, watch);
// optimizing images and calling hugo for production
exports.prod = gulp.series(imageResize, hugo);