-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
106 lines (88 loc) · 2.66 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
100
101
102
103
104
105
106
'use strict';
const gulp = require('gulp');
const rimraf = require('gulp-rimraf');
const jade = require('gulp-jade');
const browserify = require('gulp-browserify');
const babelify = require('babelify');
const sass = require('gulp-sass');
const ffmpeg = require('gulp-fluent-ffmpeg');
const sourcemaps = require('gulp-sourcemaps');
const webserver = require('gulp-webserver');
const livereload = require('gulp-livereload');
gulp.task('start', ['watch', 'serve']);
gulp.task('clean', function() {
return gulp.src('./dist', { read: false })
.pipe(rimraf());
});
gulp.task('build', ['build:js', 'build:css', 'build:img', 'build:views', 'build:audio']);
gulp.task('build:js', function() {
return gulp.src('./src/js/app.js')
.pipe(sourcemaps.init())
.pipe(browserify({
debug: true,
transform: [babelify]
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./dist/assets/js'))
.pipe(livereload());
});
gulp.task('build:css', function() {
return gulp.src('./src/scss/app.scss')
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(sourcemaps.write())
.pipe(gulp.dest('./dist/assets/css'))
.pipe(livereload());
});
gulp.task('build:img', function() {
return gulp.src('./src/img/*')
.pipe(gulp.dest('./dist/img'));
});
gulp.task('build:views', function() {
return gulp.src('./src/**/*.jade')
.pipe(jade())
.pipe(gulp.dest('./dist/'))
.pipe(livereload());
});
gulp.task('build:audio', ['audio:convert'], function() {
return gulp.src(['./src/audio/*.mp3', './src/audio/*.ogg'])
.pipe(gulp.dest('./dist/assets/audio'))
.pipe(livereload());
})
gulp.task('audio:convert', function() {
return gulp.src('./src/audio/*.wav')
.pipe(ffmpeg('mp3', function(cmd) {
return cmd
.audioBitrate('128k')
.audioChannels(2)
.audioCodec('libmp3lame')
}))
.pipe(gulp.dest('./src/audio'));
})
gulp.task('watch', ['livereload', 'watch:js', 'watch:css', 'watch:views', 'watch:audio']);
gulp.task('livereload', function() {
livereload.listen();
})
gulp.task('watch:js', function() {
gulp.watch('./src/js/**/*.js', ['build:js']);
});
gulp.task('watch:css', function() {
gulp.watch('./src/scss/**/*.scss', ['build:css']);
});
gulp.task('watch:views', function() {
gulp.watch('./src/**/*.jade', ['build:views']);
});
gulp.task('watch:audio', function() {
gulp.watch('./src/audio/*.wav', ['build:audio']);
});
gulp.task('watch:audio:convert', function() {
gulp.watch('./src/audio/*.mp3', ['build:audio'])
})
gulp.task('serve', function() {
return gulp.src('dist')
.pipe(webserver({
livereload: true,
directoryListing: false,
open: true
}));
});