-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
99 lines (85 loc) · 1.9 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
95
96
97
98
99
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var p = require('gulp-load-plugins')();
var nib = require('nib');
var rupture = require('rupture');
var jeet = require('jeet');
var autoprefixer = require('autoprefixer-stylus');
/**
* Paths & config
*/
const CONFIG = {
src: {
assets: './lib/assets/**/*',
pug: './lib/templates/**/*.jade',
stylus: './lib/styles/index.styl'
},
dest: {
dist: './dist'
},
// plugin options
options: {
pug: {
pretty: true,
locals: {}
},
stylus: {
'include-css': true,
use: [
nib(),
rupture(),
jeet(),
autoprefixer()
]
}
}
};
/**
* Default tasks & watch
*/
gulp.task('default', ['serve']);
gulp.task('build', ['copy', 'stylus', 'pug']);
gulp.task('copy', ['copy-normalize', 'copy-assets']);
gulp.task('serve', ['build'], () => {
browserSync.init({
online: false,
open: false,
reloadOnRestart: true,
notify: false,
server: {
baseDir: CONFIG.dest.dist
}
});
gulp.watch(CONFIG.src.pug, ['pug']);
gulp.watch(CONFIG.src.stylus, ['stylus']);
gulp.watch(CONFIG.src.assets, browserSync.reload);
gulp.watch('./dist/*.html', browserSync.reload);
});
/**
* Tasks
*/
gulp.task('copy-assets', () => {
return gulp
.src(CONFIG.src.assets)
.pipe(gulp.dest(CONFIG.dest.dist));
});
gulp.task('copy-normalize', () => {
return gulp
.src('./node_modules/normalize.css/normalize.css')
.pipe(gulp.dest(CONFIG.dest.dist));
});
gulp.task('pug', () => {
return gulp
.src(CONFIG.src.pug)
.pipe(p.pug(CONFIG.options.pug))
.pipe(gulp.dest(CONFIG.dest.dist));
});
gulp.task('stylus', () => {
return gulp
.src(CONFIG.src.stylus)
.pipe(p.sourcemaps.init())
.pipe(p.stylus(CONFIG.options.stylus))
.pipe(p.sourcemaps.write())
.pipe(gulp.dest(CONFIG.dest.dist))
.pipe(browserSync.stream());
});