-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgulpfile.js
More file actions
38 lines (32 loc) · 1018 Bytes
/
gulpfile.js
File metadata and controls
38 lines (32 loc) · 1018 Bytes
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
var gulp = require('gulp');
var browserify = require('gulp-browserify');
var uglify = require('gulp-uglify');
var through2 = require('through2');
var gutil = require('gulp-util');
function string2js () {
return through2.obj(function(file, encoding, callback) {
var res = file.contents.toString();
res = res.replace(/\n/g, '').replace(/\'/g, '\\\'');
res = 'module.exports = \'' + res + '\'';
file.contents = new Buffer(res);
file.path = file.path + '.js';
this.push(file);
callback();
});
}
gulp.task('buildStatic', function() {
gulp.src('./static/*')
.pipe(string2js())
.pipe(gulp.dest('./js'));
});
gulp.task('buildJs', function() {
gulp.src('./js/player.js')
.pipe(browserify().on('error', gutil.log))
.pipe(uglify())
.pipe(gulp.dest('./'));
});
gulp.task('watch', ['build'], function() {
gulp.watch(['./**/*', '!./js/*.css.js', '!./js/*.html.js'], ['build']);
});
gulp.task('build', ['buildStatic', 'buildJs']);
gulp.task('default', ['watch', 'build']);