-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.js
executable file
·85 lines (77 loc) · 1.94 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
var gulp = require('gulp');
var sass = require('gulp-sass')(require('sass'));
var cssnano = require('cssnano');
var autoprefixer = require('autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var postcss = require('gulp-postcss');
var cp = require('child_process');
var jekyll = process.platform === 'win32' ? 'jekyll.bat' : 'jekyll';
var concatjs = require('gulp-concat');
var browserSync = require('browser-sync').create();
var paths = {
styles: {
src: '_scss/**/*.scss',
dest: '_site/css',
destsecond: 'css'
},
scripts: {
src: '_js/src/*.js',
dest: '_site/js/dist/',
destsecond: 'js/dist/'
}
};
function jekyllBuild() {
return cp.spawn( jekyll , ['build'], {stdio: 'inherit'})
}
function style() {
return gulp.src(paths.styles.src)
.pipe(sass({
includePaths: ['scss'],
outputStyle: 'expanded',
onError: browserSync.notify
}))
.pipe(postcss([
autoprefixer()
]))
.pipe(gulp.dest(paths.styles.dest))
.pipe(browserSync.reload({stream:true}))
.pipe(gulp.dest(paths.styles.destsecond));
}
function js() {
return gulp.src([
'./node_modules/jquery/dist/jquery.min.js',
'./node_modules/bootstrap/dist/js/bootstrap.bundle.js',
'./node_modules/jquery-match-height/dist/jquery.matchHeight-min.js',
paths.scripts.src
])
.pipe(concatjs('app.bundle.js'))
.pipe(gulp.dest(paths.scripts.dest))
.pipe(browserSync.reload({stream:true}))
}
function browserSyncServe(done) {
browserSync.init({
server: {
baseDir: "_site"
}
})
done();
}
function browserSyncReload(done) {
browserSync.reload();
done();
}
function watch() {
gulp.watch(paths.styles.src, style)
gulp.watch(paths.scripts.src, js)
gulp.watch(
[
'*.html',
'_layouts/*.html',
'_pages/*',
'_posts/*',
'_data/*',
'_includes/*'
],
gulp.series(jekyllBuild, browserSyncReload));
}
gulp.task('default', gulp.parallel(jekyllBuild, browserSyncServe, watch))