-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
110 lines (96 loc) · 3.02 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
var pkg = require('./package.json'),
gulp = require('gulp'),
gutil = require('gulp-util'),
plumber = require('gulp-plumber'),
rimraf = require('gulp-rimraf'),
rename = require('gulp-rename'),
connect = require('gulp-connect'),
browserify = require('gulp-browserify'),
uglify = require('gulp-uglify'),
jade = require('gulp-jade'),
stylus = require('gulp-stylus'),
autoprefixer = require('gulp-autoprefixer'),
csso = require('gulp-csso'),
through = require('through'),
opn = require('opn'),
ghpages = require('gh-pages'),
path = require('path'),
isDist = process.argv.indexOf('serve') === -1;
gulp.task('js', ['clean:js'], function() {
return gulp.src('src/scripts/main.js')
.pipe(isDist ? through() : plumber())
.pipe(browserify({ transform: ['debowerify'], debug: !isDist }))
.pipe(isDist ? uglify() : through())
.pipe(rename('build.js'))
.pipe(gulp.dest('dist/build'))
.pipe(connect.reload());
});
gulp.task('html', ['clean:html'], function() {
return gulp.src('src/index.jade')
.pipe(isDist ? through() : plumber())
.pipe(jade({ pretty: true }))
.pipe(rename('index.html'))
.pipe(gulp.dest('dist'))
.pipe(connect.reload());
});
gulp.task('css', ['clean:css'], function() {
return gulp.src('src/styles/main.styl')
.pipe(isDist ? through() : plumber())
.pipe(stylus({
// Allow CSS to be imported from node_modules and bower_components
'include css': true,
'paths': ['./node_modules', './bower_components']
}))
.pipe(autoprefixer('last 2 versions', { map: false }))
.pipe(isDist ? csso() : through())
.pipe(rename('build.css'))
.pipe(gulp.dest('dist/build'))
.pipe(connect.reload());
});
gulp.task('images', ['clean:images'], function() {
return gulp.src('src/images/**/*')
.pipe(gulp.dest('dist/images'))
.pipe(connect.reload());
});
gulp.task('clean', function() {
return gulp.src('dist')
.pipe(rimraf());
});
gulp.task('clean:html', function() {
return gulp.src('dist/index.html')
.pipe(rimraf());
});
gulp.task('clean:js', function() {
return gulp.src('dist/build/build.js')
.pipe(rimraf());
});
gulp.task('clean:css', function() {
return gulp.src('dist/build/build.css')
.pipe(rimraf());
});
gulp.task('clean:images', function() {
return gulp.src('dist/images')
.pipe(rimraf());
});
gulp.task('connect', ['build'], function(done) {
connect.server({
root: 'dist',
livereload: true
});
opn('http://localhost:8080', done);
});
gulp.task('watch', function() {
gulp.watch('src/**/*.jade', ['html']);
gulp.watch('src/styles/**/*.styl', ['css']);
gulp.watch('src/images/**/*', ['images']);
gulp.watch([
'src/scripts/**/*.js',
'bespoke-theme-*/dist/*.js' // Allow themes to be developed in parallel
], ['js']);
});
gulp.task('deploy', ['build'], function(done) {
ghpages.publish(path.join(__dirname, 'dist'), { logger: gutil.log }, done);
});
gulp.task('build', ['js', 'html', 'css', 'images']);
gulp.task('serve', ['connect', 'watch']);
gulp.task('default', ['build']);