forked from night/betterttv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
60 lines (51 loc) · 1.85 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
var fs = require('fs'),
gulp = require('gulp'),
jade = require('gulp-jade'),
browserify = require('gulp-browserify'),
header = require('gulp-header'),
footer = require('gulp-footer'),
concat = require('gulp-concat'),
del = require('del'),
eslint = require('gulp-eslint'),
uglify = require('gulp-uglify'),
saveLicense = require('uglify-save-license'),
enviro = require('gulp-environments');
gulp.task('cleanup', function() {
return del('build/**/*');
});
gulp.task('templates', ['cleanup'], function() {
return gulp.src(['src/templates/*.jade'])
.pipe(jade({client: true, globals: ['$', 'window', 'bttv', 'Twitch']}))
.pipe(footer(';module.exports=template;'))
.pipe(gulp.dest('build/templates/'));
});
gulp.task('prepare', ['lint', 'templates'], function() {
return gulp.src(['src/**/*'])
.pipe(gulp.dest('build/'));
});
gulp.task('lint', function() {
var options = {
configFile: '.eslintrc'
};
return gulp.src(['src/js/**/*'])
.pipe(eslint(options))
.pipe(eslint.format())
.pipe(eslint.failOnError());
});
var jadeDefinition = fs.readFileSync('node_modules/jade/runtime.js').toString();
var license = fs.readFileSync('src/license.txt').toString();
gulp.task('scripts', ['prepare'], function() {
gulp.src(['build/js/main.js'])
.pipe(browserify())
.pipe(concat('betterttv.js'))
.pipe(header('(function(bttv) {'))
.pipe(header(jadeDefinition))
.pipe(header(license + '\n'))
.pipe(footer('}(window.BetterTTV = window.BetterTTV || {}));'))
.pipe(enviro.production(uglify({ preserveComments: saveLicense })))
.pipe(gulp.dest('build'));
});
gulp.task('watch', ['default'], function() {
gulp.watch('src/**/*', ['default']);
});
gulp.task('default', ['scripts']);