-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
61 lines (50 loc) · 1.48 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
var del = require('del');
var browserSync = require('browser-sync');
var gulp = require('gulp');
var sass = require('gulp-sass');
var ghPages = require('gulp-gh-pages');
var outDir = 'out';
var cacheDir = '.publish';
gulp.task('clean', cleaner);
gulp.task('build:assets', copyAssets);
gulp.task('build:sass', compileSass);
gulp.task('build:copyFavicons', copyFavicons);
gulp.task('build', ['build:assets', 'build:sass', 'build:copyFavicons']);
gulp.task('dev', ['build'], setupWatcher);
gulp.task('deploy', ['build'], deployToGithub);
function cleaner(cb) {
del([outDir, cacheDir], cb);
}
function copyFavicons() {
return gulp.src(['src/assets/images/favicons/**'], {dot : true})
.pipe(gulp.dest(outDir))
.pipe(browserSync.stream());
}
function copyAssets() {
return gulp.src(['src/assets/**', '!src/assets/images/favicons/', '!src/assets/images/favicons/**'], {dot : true})
.pipe(gulp.dest(outDir))
.pipe(browserSync.stream());
}
function compileSass() {
return gulp.src(['src/sass/**/*.scss', '!src/sass/**/_*.scss'])
.pipe(sass())
.pipe(gulp.dest(outDir + '/css'))
.pipe(browserSync.stream());
}
function deployToGithub() {
return gulp.src(outDir + '/**', {dot : true})
.pipe(ghPages({
branch : 'master',
cacheDir : cacheDir
}));
}
function setupWatcher() {
browserSync({
server : {
baseDir : outDir
},
open : false
});
gulp.watch(['src/sass/**'], ['build:sass']);
gulp.watch(['src/assets/**'], ['build:assets']);
}