-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
79 lines (67 loc) · 1.92 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
var gulp = require('gulp');
var gutil = require('gulp-util');
var chalk = require('chalk');
var browserSync = require('browser-sync');
var sass = require('gulp-sass');
var execFile = require('child_process').execFile;
var del = require('del');
var bower = require('main-bower-files');
var normalizeBower = require('gulp-bower-normalize');
gulp.task('serve', ['watch'], function (cb) {
browserSync.init({
server: {
baseDir: 'dist'
},
files: 'dist/**/*'
}, cb);
});
gulp.task('clean', [], function () {
return del('dist/*');
});
gulp.task('watch', ['watch:static', 'watch:styles', 'watch:pages', 'watch:bower']);
gulp.task('build', ['build:static', 'build:styles', 'build:pages', 'build:bower']);
gulp.task('watch:static', ['build:static'], function () {
gulp.watch('src/static/**/*', ['build:static']);
});
gulp.task('build:static', [], function () {
return gulp.src('src/static/**/*')
.pipe(gulp.dest('dist/assets'))
;
});
gulp.task('watch:styles', ['build:styles'], function () {
gulp.watch('src/styles/**/*.scss', ['build:styles']);
});
gulp.task('build:styles', [], function () {
return gulp.src('src/styles/**/*.scss')
.pipe(sass())
.pipe(gulp.dest('dist/assets/styles'))
;
});
gulp.task('watch:pages', ['build:pages'], function () {
gulp.watch(['src/pages/**/*.html', 'src/pages/**/*.js', 'pages.js'], ['build:pages']);
});
gulp.task('build:pages', [], function (cb) {
execFile('node', ['pages.js', 'src/pages', 'dist'], {}, function (err, stdout, stderr) {
if (err) {
gutil.log(chalk.red(err.message));
}
if (stderr) {
gutil.log(chalk.red(stderr));
}
cb();
});
});
gulp.task('watch:bower', ['build:bower'], function () {
gulp.watch('bower.json', ['build:bower']);
});
gulp.task('build:bower', [], function () {
return gulp.src(bower(), {
base: './bower_components'
})
.pipe(normalizeBower({
bowerJson: './bower.json',
flatten: true
}))
.pipe(gulp.dest('dist/assets/vendor'))
;
});