-
Notifications
You must be signed in to change notification settings - Fork 34
/
gulpfile.js
113 lines (97 loc) · 3.1 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
107
108
109
110
111
112
113
var gulp = require('gulp'),
minifyHtml = require('gulp-minify-html'),
minifyCss = require('gulp-minify-css'),
concat = require('gulp-concat'),
del = require('del'),
uglify = require('gulp-uglify'),
jshint = require('gulp-jshint'),
stylish = require('jshint-stylish'),
zip = require('gulp-zip');
//lint it out
gulp.task('hint', function () {
gulp.src(['./src/js/background/**/*', './src/js/content_script/**/*', './src/js/options/**/*', './src/js/popup/**/*'])
.pipe(jshint())
.pipe(jshint.reporter(stylish));
});
//clear out the folder
gulp.task('empty', function() {
del(['./dist/**', '!./dist', '!./dist/.gitignore', './bishop.zip']);
});
// minify our html
gulp.task('html', function () {
gulp.src('./src/html/*.html')
.pipe(minifyHtml())
.pipe(gulp.dest('./dist/'));
});
//minify & concat our CSS
gulp.task('main-css', function () {
gulp.src('./src/css/*')
.pipe(minifyCss())
.pipe(concat('style.css'))
.pipe(gulp.dest('./dist/'));
});
gulp.task('alert-css', function () {
gulp.src('./src/css/alert.css')
.pipe(minifyCss())
.pipe(concat('alert.css'))
.pipe(gulp.dest('./dist/'));
});
//minify and concat our js
//background
gulp.task('js-background', function () {
gulp.src('./src/js/background/*')
.pipe(uglify())
.pipe(concat('background.js'))
.pipe(gulp.dest('./dist/'));
});
//content_script
gulp.task('js-content', function () {
gulp.src('./src/js/content_script/*')
.pipe(uglify())
.pipe(concat('content_script.js'))
.pipe(gulp.dest('./dist/'));
});
//popup
gulp.task('js-popup', function () {
gulp.src('./src/js/popup/*')
.pipe(uglify())
.pipe(concat('popup.js'))
.pipe(gulp.dest('./dist/'));
});
//options
gulp.task('js-options', function () {
gulp.src('./src/js/options/*')
.pipe(uglify())
.pipe(concat('options.js'))
.pipe(gulp.dest('./dist/'));
});
//lib
gulp.task('js-lib', function () {
gulp.src(['./src/js/lib/jquery-1.9.1.js', './src/js/lib/bootstrap.js', './src/js/lib/bootstrap-growl.min.js', './src/js/lib/intro.js'])
.pipe(uglify())
.pipe(concat('lib.js'))
.pipe(gulp.dest('./dist/'));
});
//move over remaining files
gulp.task('copy', function () {
return gulp.src(['./src/audio/**/*', './src/img/**/*', './src/fonts/**/*', './src/manifest.json'], {
base: 'src'
}).pipe(gulp.dest('./dist'));
});
gulp.task('zip', ['default'], function () {
return gulp.src('dist/**/*')
.pipe(zip('bishop.zip'))
.pipe(gulp.dest('./'));
});
//tie it all together
gulp.task('js', ['js-background', 'js-content', 'js-popup', 'js-options', 'js-lib'])
gulp.task('css', ['main-css', 'alert-css'])
//realtime watching
gulp.task('realtime', function() {
gulp.watch('./src/js/**/*', ['js']);
gulp.watch('./src/html/**/*', ['html']);
gulp.watch('./src/css/**/*', ['css']);
gulp.watch(['./src/audio/**/*', './src/img/**/*', './src/fonts/**/*', './src/manifest.json'], ['copy']);
});
gulp.task('watch', ['realtime', 'html', 'css', 'js', 'copy']);
gulp.task('default', ['hint', 'html', 'css', 'js', 'copy']);