-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.js
114 lines (94 loc) · 3.15 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
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
sass = require('gulp-sass'),
cleanCSS = require('gulp-clean-css'),
sourcemaps = require('gulp-sourcemaps'),
filter = require('gulp-filter'),
concat = require('gulp-concat'),
cp = require('child_process'),
browserSync = require('browser-sync').create();
function js() {
var files = [
'node_modules/material-design-lite/material.min.js',
'node_modules/jquery/dist/jquery.min.js',
'node_modules/packery/dist/packery.pkgd.min.js',
'node_modules/flickity/dist/flickity.pkgd.min.js',
'node_modules/clipboard/dist/clipboard.min.js',
'node_modules/anchor-js/anchor.min.js',
'node_modules/mustache/mustache.min.js',
'node_modules/lunr/lunr.js',
'node_modules/photoswipe/dist/photoswipe.min.js',
'node_modules/photoswipe/dist/photoswipe-ui-default.min.js',
'js/*'
];
var local = filter('js/*.js', {restore: true});
return gulp.src(files)
.pipe(local)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(local.restore)
.pipe(uglify())
.pipe(concat('all.js'))
.pipe(gulp.dest('assets'));
}
function css() {
var files = [
// 'node_modules/material-design-lite/material.min.css',
'node_modules/flickity/dist/flickity.min.css',
'node_modules/photoswipe/dist/photoswipe.css',
'node_modules/photoswipe/dist/default-skin/default-skin.css',
'css/*.css',
'css/main.scss'
];
var scss = filter('css/*.scss', {restore: true});
return gulp.src(files)
.pipe(sourcemaps.init())
.pipe(scss)
.pipe(sass.sync().on('error', sass.logError))
.pipe(scss.restore)
.pipe(cleanCSS({keepSpecialComments: 0, rebase: false}))
.pipe(concat('almost-all.css'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('assets'));
}
function images() {
var files = [
'node_modules/photoswipe/dist/default-skin/*.{svg,png,gif}'
];
return gulp.src(files)
.pipe(gulp.dest('assets'));
}
function browser(cb) {
browserSync.reload();
cb();
}
function jekyllBuild(incremental) {
var command = 'bundle exec jekyll build';
if (incremental) {
command += ' --incremental';
}
return cp.exec(command);
}
function jekyll() {
browserSync.notify("'jekyll build' is running", 10000);
return jekyllBuild();
}
function jekyllIncremental() {
browserSync.notify("'jekyll build -I' is running", 10000);
return jekyllBuild(true);
}
const fullRefresh = gulp.series(jekyll, browser);
const partialRefresh = gulp.series(jekyllIncremental, browser);
function serve() {
browserSync.init({
server: '_site',
open: false
});
gulp.watch(['js/*'], js);
gulp.watch(['css/**/*'], css);
gulp.watch(['_data/**/*', '_includes/**/*', 'assets/*', 'images/**/*'], fullRefresh);
gulp.watch(['_layouts/*', '_posts/*', 'm1/**/*', 'm2/**/*', 'shopify/**/*'], partialRefresh);
}
exports.default = gulp.series(jekyll, serve);
exports.assets = gulp.parallel(js, css, images);