forked from longpdo/neumorphism
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·137 lines (123 loc) · 3.02 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
var gulp = require('gulp');
var browserSync = require('browser-sync');
var sass = require('gulp-sass')(require('sass'));
var cssnano = require('gulp-cssnano');
var prefix = require('gulp-autoprefixer');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var cp = require('child_process');
/**
* Compile and minify sass
*/
function styles() {
return gulp
.src([ '_sass/*.scss' ])
.pipe(
sass({
includePaths: [ 'scss' ],
onError: browserSync.notify
})
)
.pipe(prefix([ 'last 3 versions', '> 1%', 'ie 8' ], { cascade: true }))
.pipe(rename('main.min.css'))
.pipe(cssnano())
.pipe(gulp.dest('_site/assets/css/'))
.pipe(browserSync.reload({ stream: true }))
.pipe(gulp.dest('assets/css'));
}
function stylesVendors() {
return gulp
.src([ '_sass/vendors/*.css' ])
.pipe(concat('vendors.min.css'))
.pipe(cssnano())
.pipe(gulp.dest('_site/assets/css/'))
.pipe(gulp.dest('assets/css'));
}
/**
* Compile and minify js
*/
function scripts() {
return gulp
.src([ '_js/app.js' ])
.pipe(rename('app.min.js'))
.pipe(uglify())
.pipe(gulp.dest('_site/assets/js'))
.pipe(browserSync.reload({ stream: true }))
.pipe(gulp.dest('assets/js'));
}
function scriptsVendors() {
return gulp
.src([ '_js/vendors/*.js' ])
.pipe(concat('vendors.min.js'))
.pipe(uglify())
.pipe(gulp.dest('_site/assets/js'))
.pipe(gulp.dest('assets/js'));
}
/**
* Server functionality handled by BrowserSync
*/
function browserSyncServe(done) {
browserSync.init({
server: '_site',
port: 4000
});
done();
}
function browserSyncReload(done) {
browserSync.reload();
done();
}
/**
* Build Jekyll site
*/
function jekyll(done) {
return cp
.spawn(
'bundle',
[
'exec',
'jekyll',
'build',
'--incremental',
'--config=_config.yml,_config_dev.yml'
],
{
stdio: 'inherit'
}
)
.on('close', done);
}
/**
* Watch source files for changes & recompile
* Watch html/md files, run Jekyll & reload BrowserSync
*/
function watchData() {
gulp.watch(
[ '_data/*.yml', '_config.yml', 'assets/*.json' ],
gulp.series(jekyll, browserSyncReload)
);
}
function watchMarkup() {
gulp.watch(
[ 'index.html', '_includes/*.html', '_layouts/*.html' ],
gulp.series(jekyll, browserSyncReload)
);
}
function watchScripts() {
gulp.watch([ '_js/*.js' ], scripts);
}
function watchStyles() {
gulp.watch([ '_sass/*.scss' ], styles);
}
function watch() {
gulp.parallel(watchData, watchMarkup, watchScripts, watchStyles);
}
var compile = gulp.parallel(styles, stylesVendors, scripts, scriptsVendors);
var serve = gulp.series(compile, jekyll, browserSyncServe);
var watch = gulp.parallel(watchData, watchMarkup, watchScripts, watchStyles);
/**
* Default task, running just `gulp` will compile the sass,
* compile the Jekyll site, launch BrowserSync & watch files.
*/
gulp.task('default', gulp.parallel(serve, watch));