-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
134 lines (100 loc) · 2.86 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
130
131
132
133
134
var gulp = require('gulp');
var deploy = require('gulp-gh-pages');
var rimraf = require('gulp-rimraf');
var minify = require('gulp-clean-css');
var concat = require('gulp-concat');
var templates = require('gulp-jade');
var stylus = require('gulp-stylus');
var sourcemaps = require('gulp-sourcemaps');
var livereload = require('gulp-livereload');
var runseq = require('run-sequence');
var open = require('open');
// server stuff
var connect = require('connect');
var serveStatic = require('serve-static');
var serveIndex = require('serve-index');
var connectLivereload = require('connect-livereload');
var paths = {
assets: ['./app/assets/**/*', './app/assets/.travis.yml'],
stylus: ['app/**/*.styl', 'app/**/*.css', '!app/**/_*.styl'],
templates: ['app/**/*.jade', '!app/**/_*.jade']
};
// BUILD
gulp.task('assets', function () {
return gulp.src(paths.assets)
.pipe(gulp.dest('./public'));
});
gulp.task('stylus', function () {
return gulp.src(paths.stylus)
.pipe(sourcemaps.init())
.pipe(stylus({
use: require('nib')()
}))
.pipe(concat('app.css'))
.pipe(sourcemaps.write('../maps/', {sourceRoot: '../app/'}))
.pipe(gulp.dest('./public/css'));
});
gulp.task('templates', function () {
return gulp.src(paths.templates)
.pipe(templates())
.pipe(gulp.dest('./public'));
});
// PRODUCTION BUILD
gulp.task('stylus:prod', function () {
return gulp.src(paths.stylus)
.pipe(stylus({
use: require('nib')()
}))
.pipe(concat('app.css'))
.pipe(minify())
.pipe(gulp.dest('./public/css'));
});
gulp.task('clean', function () {
return gulp.src('./public', {read: false})
.pipe(rimraf());
});
gulp.task('build', ['templates', 'stylus', 'assets']);
gulp.task('build:prod', function (cb) {
runseq(
'clean',
['templates', 'stylus:prod', 'assets'],
cb
);
});
// DEVELOPMENT
gulp.task('serve', ['build'], function () {
var port = livereload.listen().port;
connect()
.use(connectLivereload({
port: port
}))
.use(serveStatic('public/'))
.use(serveIndex('public/'))
.listen(3000, '0.0.0.0');
gulp.watch(['public/**/*'], function (file) {
livereload.changed(file.path);
});
});
gulp.task('watch', ['build'], function () {
gulp.watch(paths.assets, ['assets']);
gulp.watch(['app/**/*.styl'], ['stylus']);
gulp.watch(['app/**/*.jade'], ['templates']);
});
gulp.task('open', ['serve'], function () {
open('http://localhost:3000');
});
gulp.task('dev', ['watch', 'serve', 'open']);
// DEPLOYMENT
gulp.task('deploy', ['build:prod'], function () {
return gulp.src(['./public/**/*', './public/.travis.yml'])
.pipe(deploy({
branch: 'master'
}));
});
gulp.task('travis-deploy', ['build:prod'], function () {
return gulp.src(['./public/**/*', './public/.travis.yml'])
.pipe(deploy({
branch: 'master',
remoteUrl: process.env.GIT_REPO
}));
});