-
Notifications
You must be signed in to change notification settings - Fork 170
/
gulpfile.babel.js
62 lines (52 loc) · 1.6 KB
/
gulpfile.babel.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
import gulp from 'gulp';
import util from 'gulp-util';
import express from 'express';
import connect from 'connect-livereload';
import refresh from 'gulp-refresh';
import path from 'path';
import sass from 'gulp-sass';
import jade from 'gulp-jade';
import plumber from 'gulp-plumber';
const app = express();
const build_path = '_public';
gulp.task('sass', () =>
gulp.src('sass/*.sass')
.pipe(plumber({errorHandler: (error) => util.log(util.colors.red, error.message)}))
.pipe(sass({includePaths: 'node_modules/compass-mixins/lib'})
.on('error', sass.logError))
.pipe(gulp.dest(`${build_path}/css`))
.pipe(refresh())
);
gulp.task('jade', () =>
gulp.src(['views/index.jade', 'views/404.jade'])
.pipe(plumber())
.pipe(jade())
.pipe(gulp.dest(`${build_path}`))
.pipe(refresh())
);
gulp.task('assets', () =>
gulp.src('assets/**/*')
.pipe(gulp.dest(`${build_path}/assets`))
.pipe(refresh())
);
gulp.task('js',() =>
gulp.src('js/*.js')
.pipe(gulp.dest(`${build_path}/js`))
.pipe(refresh())
);
gulp.task('server', () => {
app.use(connect());
app.use(express.static(path.resolve(`${build_path}`)));
app.get('/*', (req, res) => res.sendFile(path.resolve(`${build_path}/index.html`)));
app.listen(3000);
util.log('listening on port 3000');
});
gulp.task('watch', () => {
refresh.listen({start: true});
gulp.watch('sass/*.sass', ['sass']);
gulp.watch('views/*.jade', ['jade']);
gulp.watch('js/*js', ['js']);
});
gulp.task('build', ['jade', 'sass', 'js', 'assets']);
gulp.task('dev', ['build', 'server', 'watch']);
gulp.task('default', ['build']);