-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
89 lines (73 loc) · 2.05 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
'use strict';
const gulp = require('gulp')
const gutil = require('gulp-util')
const pug = require('gulp-pug')
const sass = require('gulp-sass')
const ghPages = require('gulp-gh-pages')
const browserSync = require('browser-sync').create()
const babel = require('gulp-babel')
const PATH = {
npm: './node_modules',
assets: './src/assets',
dist: './dist',
src: './src'
}
const GLOB = {
publish: PATH.dist + '/**/*',
pug: PATH.src + '/**/!(_)*.pug',
pugWatch: PATH.src + '/**/*.pug',
sass: PATH.assets + '/sass/style.scss',
sassWatch: PATH.assets + '/sass/**/*.scss',
js: PATH.assets + '/js/**/*.js',
copy: ['./src/CNAME', './src/**/*.?(png|ico|js|svg)']
}
const DEST = {
sass: PATH.dist + '/assets/css',
libs: PATH.dist + '/assets/libs'
}
const LIBS = [
'jquery/dist/jquery.min.js',
'two.js/build/two.min.js'
]
gulp.task('default', ['build'])
gulp.task('watch', ['build'], () => {
browserSync.init({
server: './dist'
})
gulp.watch(GLOB.sassWatch, ['sass'])
gulp.watch(GLOB.pugWatch, ['pug']).on('change', browserSync.reload)
gulp.watch(GLOB.js, ['js']).on('change', browserSync.reload)
})
gulp.task('build', ['pug', 'sass', 'copy'])
gulp.task('publish', ['build'], () => {
return gulp.src(GLOB.publish)
.pipe(ghPages({branch: 'master', force: true}))
})
gulp.task('pug', () => {
return gulp.src(GLOB.pug, {base: PATH.src})
.pipe(pug())
.on('error', gutil.log)
.pipe(gulp.dest(PATH.dist))
})
gulp.task('sass', () => {
return gulp.src(GLOB.sass)
.pipe(sass())
.on('error', gutil.log)
.pipe(gulp.dest(DEST.sass))
.pipe(browserSync.stream())
})
gulp.task('js', () => {
return gulp.src(GLOB.js, {base: PATH.src})
.pipe(babel())
.on('error', gutil.log)
.pipe(gulp.dest(PATH.dist))
})
gulp.task('copy', ['copyLibs'], () => {
gulp.src('.gitignore').pipe(gulp.dest(PATH.dist))
return gulp.src(GLOB.copy, {base: PATH.src})
.pipe(gulp.dest(PATH.dist))
})
gulp.task('copyLibs', () => {
return gulp.src(LIBS.map(l => PATH.npm + '/' + l))
.pipe(gulp.dest(DEST.libs))
})