-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
94 lines (85 loc) · 2.11 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
/*global require*/
"use strict";
var gulp = require('gulp'),
path = require('path'),
data = require('gulp-data'),
pug = require('gulp-pug'),
prefix = require('gulp-autoprefixer'),
sass = require('gulp-sass'),
browserSync = require('browser-sync');
/*
* Directories here
*/
var paths = {
app: './app/',
sass: './src/sass/',
css: './app/css/',
data: './src/_data/'
};
/**
* Compile .pug files and pass in data from json file
* matching file name. index.pug - index.pug.json
*/
gulp.task('pug', function () {
return gulp.src('./src/*.pug')
.pipe(pug({
pretty: true
}))
.on('error', function (err) {
process.stderr.write(err.message + '\n');
this.emit('end');
})
.pipe(gulp.dest(paths.app));
});
/**
* Recompile .pug files and live reload the browser
*/
gulp.task('rebuild', ['pug'], function () {
browserSync.reload();
});
/**
* Wait for pug and sass tasks, then launch the browser-sync Server
*/
gulp.task('browser-sync', ['sass', 'pug'], function () {
browserSync({
server: {
baseDir: paths.app
},
notify: false
});
});
/**
* Compile .sass files into public css directory With autoprefixer no
* need for vendor prefixes then live reload the browser.
*/
gulp.task('sass', function () {
return gulp.src(paths.sass + '*.sass')
.pipe(sass({
includePaths: [paths.sass],
outputStyle: 'expanded'
}))
.on('error', sass.logError)
//.pipe(prefix(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], {
// cascade: true
//}))
.pipe(gulp.dest(paths.css))
.pipe(browserSync.reload({
stream: true
}));
});
/**
* Watch .sass files for changes & recompile
* Watch .pug files run pug-rebuild then reload BrowserSync
*/
gulp.task('watch', function () {
gulp.watch(paths.sass + '**/*.sass', ['sass']);
gulp.watch('./src/**/*.pug', ['rebuild']);
});
// Build task compile sass and pug.
gulp.task('build', ['sass', 'pug']);
/**
* Default task, running just `gulp` will compile the sass,
* compile the jekyll site, launch BrowserSync then watch
* files for changes
*/
gulp.task('default', ['browser-sync', 'watch']);