-
Notifications
You must be signed in to change notification settings - Fork 12
/
gulpfile.js
129 lines (107 loc) · 3.33 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
'use strict';
var gulp = require('gulp');
var del = require('del');
var haml = require('gulp-haml');
var coffee = require('gulp-coffee');
var coffeelint = require('gulp-coffeelint');
var jsontf = require('gulp-json-transform');
var stylish = require('coffeelint-stylish');
var sass = require('gulp-sass');
var gutil = require('gulp-util');
var tinylr = require('tiny-lr');
// Copy static folders to build directory
gulp.task('update-static', function() {
del('build/*/assets/fonts/*');
gulp.src('src/assets/fonts/**')
.pipe(gulp.dest('build/chrome/assets/fonts'))
.pipe(gulp.dest('build/firefox/assets/fonts'));
del('build/*/assets/icons/*');
gulp.src('src/assets/icons/**')
.pipe(gulp.dest('build/chrome/assets/icons'))
.pipe(gulp.dest('build/firefox/assets/icons'));
del('build/*/assets/images/*');
gulp.src('src/assets/images/**')
.pipe(gulp.dest('build/chrome/assets/images'))
.pipe(gulp.dest('build/firefox/assets/images'));
del('build/*/assets/vendor/*');
gulp.src('src/scripts/vendor/*.js')
.pipe(gulp.dest('build/chrome/scripts/vendor'))
.pipe(gulp.dest('build/firefox/scripts/vendor'));
del('build/*/manifest.json');
return gulp.src('src/manifest.json')
.pipe(gulp.dest('build/chrome'))
.pipe(jsontf(function(data, file) {
data.applications = {
"gecko": {
"id": "[email protected]"
}
};
return data;
}, 2))
.pipe(gulp.dest('build/firefox'));
});
// HAML
gulp.task('haml', function () {
del('build/*/popup.html');
gulp.src('src/popup.haml')
.pipe(haml())
.pipe(gulp.dest('build/chrome'))
.pipe(gulp.dest('build/firefox'));
});
// Coffee
gulp.task('coffee', function() {
del('build/*/scripts/*.js');
gulp.src('src/scripts/*.coffee')
// .pipe(coffeelint(null, {disable: 'max_line_length'}))
// .pipe(coffeelint.reporter(stylish))
.pipe(coffee({bare: true}).on('error', gutil.log))
.pipe(gulp.dest('build/chrome/scripts/'))
.pipe(gulp.dest('build/firefox/scripts/'));
});
// SASS
gulp.task('sass', function () {
del('build/*/styles/*.css');
gulp.src('src/styles/*.sass')
.pipe(sass({outputStyle: 'compressed'}))
.pipe(gulp.dest('build/chrome/styles'))
.pipe(gulp.dest('build/firefox/styles'));
});
// Watch paths
var watchPaths = {
coffee: [
'src/scripts/*.coffee',
'src/scripts/vendor/*.coffee'
],
assets: [
'src/assets/**',
'src/assets/**/*',
'src/manifest.json'
],
sass: [
'src/styles/*.sass',
],
haml: [
'src/*.haml',
]
};
// Watch task
gulp.task('watch', function() {
gulp.watch(watchPaths.coffee, ['coffee']);
gulp.watch(watchPaths.assets, ['update-static']);
gulp.watch(watchPaths.sass, ['sass']);
gulp.watch(watchPaths.haml, ['haml']);
// Auto reload chrome extension
var livereload = tinylr();
livereload.listen(35729);
gulp.watch(['build/chrome/**/*', 'build/chrome/scripts/**/*'], function (evt) {
console.log('reload!')
livereload.changed({
body: {
files: [evt.path]
}
});
});
});
gulp.task('build', ['update-static', 'haml', 'coffee', 'sass'], function() {} );
// Default gulp is watch
gulp.task('default', ['watch'], function() {} );