-
Notifications
You must be signed in to change notification settings - Fork 7
/
gulpfile.js
121 lines (102 loc) · 3.42 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
require('events').EventEmitter.prototype._maxListeners = 99;
var gulp = require('gulp'),
gulpCache = require('gulp-cached'),
gulpCoffee = require('gulp-coffee'),
gulpConcat = require('gulp-concat'),
gulpConnect = require('gulp-connect'),
gulpIf = require('gulp-if'),
gulpJade = require('gulp-jade'),
gulpPlumber = require('gulp-plumber'),
gulpSass = require('gulp-sass'),
gulpUglify = require('gulp-uglify'),
gulpUtil = require('gulp-util'),
gulpWatch = require('gulp-watch'),
modRewrite = require('connect-modrewrite'),
del = require('del'),
rimraf = require('rimraf');
var errorHandler = function(error) {
gulpUtil.log(error);
}
var dest = 'dist/';
// ----------------------------------------------------------------------------
// Production tasks
// ----------------------------------------------------------------------------
gulp.task('clean', function(callback) {
del('.tmp', callback);
});
gulp.task('serve', function() {
gulpConnect.server({
root: '.tmp',
port: 9000,
middleware: function(connect, options) {
var middlewares = [];
middlewares.push(modRewrite([
'^/examples/([a-z,\-]*)/(.*)$ /examples/$1/$2 [L]',
'^/examples/([a-z,\-]*)$ /examples/$1/index.html [L]'
]));
middlewares.push(connect.static('.tmp'));
return middlewares;
}
});
});
gulp.task('jade', function() {
return gulp.src('examples/**/*.jade')
.pipe(gulpPlumber({errorHandler:errorHandler}))
.pipe(gulpCache(('jade')))
.pipe(gulpJade({pretty: true}))
.pipe(gulp.dest('.tmp/examples/'));
});
gulp.task('coffee', function() {
return gulp.src('examples/**/*.coffee')
.pipe(gulpPlumber({errorHandler:errorHandler}))
.pipe(gulpCache('coffee'))
.pipe(gulpCoffee({bare: true, map: true, compile: true}))
.pipe(gulp.dest('.tmp/examples/'));
});
gulp.task('watch', ['clean'], function() {
gulpWatch('examples/**/*.jade', {ignoreInitial: false}, function() {
gulp.start('jade');
});
gulpWatch('examples/**/*.coffee', {ignoreInitial: false}, function() {
gulp.start('coffee');
});
});
gulp.task('build-clean', function(callback) {
rimraf('dist', callback);
});
gulp.task('build-coffee', ['build-clean'], function() {
source = [
'src/intro.js',
'src/config/**/*.coffee',
'src/modules/**/*.coffee',
'src/directives/**/*.coffee',
'src/factories/**/*.coffee',
'src/filters/**/*.coffee',
'src/prototypes/**/*.coffee',
'src/services/**/*.coffee',
'src/main.coffee',
'src/outro.js'
]
gulp.src(source)
.pipe(gulpIf('*.coffee', gulpCoffee({bare: true, map: true, compile: true})))
.pipe(gulpConcat("starqle-ng-util.js"))
.pipe(gulp.dest(dest));
return gulp.src(source)
.pipe(gulpIf('*.coffee', gulpCoffee({bare: true, map: true, compile: true})))
.pipe(gulpConcat("starqle-ng-util.min.js"))
.pipe(gulpUglify())
.pipe(gulp.dest(dest));
});
gulp.task('build-sass', [], function() {
return gulp.src(['styles/starqle-ng-util.scss'])
.pipe(gulpPlumber({errorHandler:errorHandler}))
.pipe(gulpSass())
.pipe(gulpPlumber.stop())
.pipe(gulp.dest(dest));
});
gulp.task('build', ['build-coffee', 'build-sass']);
gulp.task('examples', ['serve', 'watch']);
// ----------------------------------------------------------------------------
// Default task
// ----------------------------------------------------------------------------
gulp.task('default', ['build']);