This repository has been archived by the owner on Mar 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
108 lines (89 loc) · 2.85 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
var gulp = require('gulp');
var es = require('event-stream');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var path = require('path');
gulp.task('clean', function (cb) {
var del = require('del');
del([
// delete everything under public directory
'./public/*',
// except images, very long to generate
'!./public/img',
// except Git files
'!./public/.git',
'!./public/.gitignore'
], cb);
});
gulp.task('clean-img', function (cb) {
require('del')([
'./public/img'
], cb);
});
gulp.task('css', ['clean'], function () {
var sass = require('gulp-sass');
var minifyCSS = require('gulp-minify-css');
// keep stream CSS after Sass pre-processing
var appFile = gulp.src('./app/styles/*.scss')
.pipe(sass());
// concat and minify CSS files and stream CSS
return es.concat(gulp.src('./app/assets/css/*.css'), appFile)
.pipe(concat('app.css'))
.pipe(minifyCSS())
.pipe(rename('app.min.css'))
.pipe(gulp.dest('./public/css'));
});
gulp.task('html-min', ['clean', 'bower'], function() {
var wiredep = require('wiredep').stream;
var htmlmin = require('gulp-htmlmin');
return gulp.src('./app/assets/*.html')
.pipe(wiredep({ignorePath: '../../'}))
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest('./public'));
});
gulp.task('image-min', ['clean-img'], function () {
var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
return gulp.src('./app/assets/img/**/*')
.pipe(imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant()]
}))
.pipe(gulp.dest('./public/img'));
});
gulp.task('copy-fonts', ['clean'], function() {
return gulp.src(['./app/assets/fonts/**'])
.pipe(gulp.dest('./public/fonts'));
});
gulp.task('copy-travis', ['clean'], function() {
return gulp.src(['./.travis.yml'])
.pipe(gulp.dest('./public/'));
});
gulp.task('bower', ['clean'], function() {
var bower = require('gulp-bower');
return bower()
.pipe(gulp.dest('./public/bower_components'));
});
gulp.task('deploy_integ', ['build'], function(cb) {
var ghPages = require('gh-pages');
ghPages.publish('./public', {
clone: path.relative(process.cwd(), path.resolve(__dirname, '.cache/integ')),
logger: function(message) {
console.log(message);
}
}, cb);
});
gulp.task('deploy_prod', ['build'], function(cb) {
var ghPages = require('gh-pages');
ghPages.publish('./public', {
clone: path.relative(process.cwd(), path.resolve(__dirname, '.cache/prod')),
branch: 's3',
dotfiles: true,
logger: function(message) {
console.log(message);
}
}, cb);
});
gulp.task('build-fast', ['clean', 'copy-fonts', 'copy-travis', 'css', 'html-min']);
gulp.task('build', ['build-fast', 'image-min']);