-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
71 lines (55 loc) · 2.19 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
/**
* Created by matthew on 12/31/14.
*/
// modules
var gulp = require('gulp');
var transform = require('vinyl-transform');
var concat = require('gulp-concat');
var coffee = require('gulp-coffee');
var haml = require('gulp-haml');
var scripts = ['app/scripts/content/*', 'app/scripts/background/*', 'app/scripts/app/*', 'app/scripts/helpers/*'];
var views = ['app/views/*'];
var mainFiles = ['app/scripts/content/content.js', 'app/scripts/background/background.js', 'app/scripts/app/app.js'];
gulp.task('concat', function () {
var dest = 'app/scripts/static/';
var browserified = transform(function (filename) {
var file = filename;
var b = concat(filename, {
debug: true
});
// you can now further configure/manipulate your bundle
// you can perform transforms, for e.g.: 'coffeeify'
// b.transform('coffeeify');
// or even use concat plugins, for e.g. 'minifyiy'
// b.plugins('minifyify');
// consult concat documentation at: https://github.com/substack/node-concat#methods for more available APIs
return b.bundle();
});
var folders = ['app/scripts/app/*', 'app/scripts/background/*', 'app/scripts/content/*'];
var outputs = ['app.js', 'background.js', 'content.js'];
folders.forEach(function (input, index) {
return gulp.src(['app/scripts/helpers/*', input])
.pipe(concat(outputs[index]))
.pipe(coffee())
.pipe(gulp.dest(dest));
});
});
gulp.task('haml', function () {
gulp.src('./app/views/index.haml')
.pipe(haml())
.pipe(gulp.dest('./app/'));
});
gulp.task('js2coffee', function () {
var folders = ['app/scripts/app/*', 'app/scripts/background/*', 'app/scripts/content/*', 'app/scripts/helpers/*'];
var outputs = ['app/scripts/app/', 'app/scripts/background/', 'app/scripts/content', 'app/scripts/helpers/'];
folders.forEach(function (input, index) {
return gulp.src(input)
.pipe(js2coffee())
.pipe(gulp.dest(outputs[index]))
})
});
gulp.task('watch', function () {
gulp.watch(scripts, ['concat']);
gulp.watch(views, ['haml']);
});
gulp.task('default', ['concat', 'haml', 'watch']);