-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
85 lines (77 loc) · 2.03 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
const gulp = require('gulp');
const stylus = require('gulp-stylus');
const jade = require('gulp-pug');
const babel = require('gulp-babel');
const cleanCSS = require('gulp-clean-css');
const del = require('del');
const browserSync = require('browser-sync');
const paths = {
styles: {
src: 'src/**/*.styl',
dest: 'public/assets/'
},
scripts: {
src: 'src/**/*.js',
dest: 'public/assets/'
},
templates: {
src: './src/**/*.jade',
dest: 'public'
}
};
function serve() {
browserSync({
server: {
baseDir: './public'
}
});
};
/* Not all tasks need to use streams, a gulpfile is just another node program
* and you can use all packages available on npm, but it must return either a
* Promise, a Stream or take a callback and call it
*/
function clean() {
// You can use multiple globbing patterns as you would with `gulp.src`,
// for example if you are using del 2.0 or above, return its promise
return del([ 'public/assets' ]);
}
/*
* Define our tasks using plain functions
*/
function styles() {
return gulp.src(paths.styles.src)
.pipe(stylus())
.pipe(cleanCSS())
.pipe(gulp.dest(paths.styles.dest));
}
function scripts() {
return gulp.src(paths.scripts.src, { sourcemaps: true })
.pipe(babel())
.pipe(gulp.dest(paths.scripts.dest));
}
function watch() {
gulp.watch(paths.scripts.src, scripts);
gulp.watch(paths.styles.src, styles);
}
function templates() {
var locs = {};
return gulp.src(paths.templates.src)
.pipe(jade({locals: locs}))
.pipe(gulp.dest(paths.templates.dest))
}
/*
* Specify if tasks run in series or parallel using `gulp.series` and `gulp.parallel`
*/
var build = gulp.series(clean, gulp.parallel(styles, scripts, templates), serve);
/*
* You can use CommonJS `exports` module notation to declare tasks
*/
exports.clean = clean;
exports.styles = styles;
exports.scripts = scripts;
exports.watch = watch;
exports.build = build;
/*
* Define default task that can be called by just running `gulp` from cli
*/
exports.default = build;