-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
91 lines (83 loc) · 2.2 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var cssnano = require('cssnano');
var autoprefixer = require('autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var postcss = require('gulp-postcss');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var cp = require('child_process');
var flatten = require('gulp-flatten');
var jekyll = process.platform === 'win32' ? 'jekyll.bat' : 'jekyll';
var source = require('vinyl-source-stream');
var concatjs = require('gulp-concat');
var browserSync = require('browser-sync').create();
var paths = {
styles: {
src: '_sass/**/main.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/popper.js/dist/umd/popper.min.js',
// './node_modules/bootstrap/dist/js/bootstrap.min.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/*.yml',
'_data/*.json',
'_includes/*'
],
gulp.series(jekyllBuild, browserSyncReload));
}
gulp.task('default', gulp.parallel(jekyllBuild, browserSyncServe, watch))