-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
executable file
·68 lines (60 loc) · 1.55 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
/*jslint node: true */
'use strict';
var gulp = require('gulp');
var stylus = require('gulp-stylus');
var babel = require('gulp-babel');
var pug = require('gulp-pug');
var htmlmin = require('gulp-htmlmin');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
var path = {
pug: 'src/*.pug',
js: 'src/js/**/*.js',
stylesWatch: 'src/styles/**/*.styl',
stylesInput: 'src/styles/styles.styl',
output: 'docs',
outputJS: 'docs/js/*.js',
outputHTML: 'docs/index.html'
};
gulp.task('styles', function () {
gulp.src(path.stylesInput)
.pipe(stylus({
paths: ['node_modules'],
'include css': true,
compress: true
}))
.pipe(gulp.dest(path.output))
.pipe(browserSync.stream());
});
gulp.task('js', function () {
gulp.src(path.js)
.pipe(babel({
presets: ['env']
}))
.pipe(gulp.dest(path.output+'/js'));
});
gulp.task('minify', function () {
return gulp.src(path.pug)
.pipe(pug())
.pipe(htmlmin({
collapseWhitespace: true
}))
.pipe(gulp.dest(path.output));
});
gulp.task('observeFiles', function () {
gulp.watch(path.stylesWatch, ['styles']);
gulp.watch(path.js, ['js']);
gulp.watch(path.pug, ['minify']);
gulp.watch(path.outputHTML).on('change', reload);
gulp.watch(path.outputJS).on('change', reload);
});
gulp.task('browserSync', function () {
browserSync.init({
server: {
baseDir: path.output,
index: 'index.html'
}
});
});
gulp.task('build', ['styles', 'js', 'minify']);
gulp.task('default', ['build', 'observeFiles', 'browserSync']);