-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
117 lines (99 loc) · 3.09 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
'use strict';
var pkg = require('./package.json'),
gulp = require('gulp'),
gutil = require('gulp-util'),
plumber = require('gulp-plumber'),
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'),
del = require('del'),
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(done) {
del('dist', done);
});
gulp.task('clean:html', function(done) {
del('dist/index.html', done);
});
gulp.task('clean:js', function(done) {
del('dist/build/build.js', done);
});
gulp.task('clean:css', function(done) {
del('dist/build/build.css', done);
});
gulp.task('clean:images', function(done) {
del('dist/images', done);
});
gulp.task('connect', ['build'], function() {
connect.server({
root: ['dist', 'poc'],
livereload: true
});
});
gulp.task('open', ['connect'], function (done) {
opn('http://localhost:8080', done);
});
gulp.task('poc', function() {
return gulp.src('poc/**/*')
.pipe(connect.reload());
});
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.watch('poc/**/*', ['poc']);
});
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', ['open', 'watch']);
gulp.task('default', ['build']);