-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
75 lines (63 loc) · 1.95 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
'use strict';
var gulp = require('gulp');
var config = require('./gulp-config.json');
var $ = {
if: require('gulp-if'),
notify: require('gulp-notify'),
rev: require('gulp-rev'),
revReplace: require('gulp-rev-replace'),
useref: require('gulp-useref'),
filter: require('gulp-filter'),
uglify: require('gulp-uglify'),
minifyCss: require('gulp-minify-css'),
del: require('del'),
path: require('path'),
connect: require('connect'),
serveStatic: require('serve-static'),
log: require('gulp-load-plugins')()
.loadUtils(['log'])
.log
};
gulp.task('fonts', function(){
return gulp
.src([$.path.join(config.paths.client, 'content/fonts/*')])
.pipe(gulp.dest($.path.join(config.paths.destination, 'content/fonts')));
});
gulp.task('images', function(){
return gulp
.src([$.path.join(config.paths.client, 'content/images/*')])
.pipe(gulp.dest($.path.join(config.paths.destination, 'content/images')));
});
gulp.task('build', ['fonts', 'images'], function() {
var cssFilter = $.filter('**/*.css');
var jsFilter = $.filter('**/*.js');
var assets = $.useref.assets();
return gulp
.src($.path.join(config.paths.client, '*.html'))
.pipe(assets)
.pipe($.if('*.js', $.uglify()))
.pipe($.if('*.css', $.minifyCss()))
.pipe($.rev())
.pipe(assets.restore())
.pipe($.useref())
.pipe($.revReplace())
.pipe(gulp.dest(config.paths.destination))
.pipe($.notify({
onLast: true,
message: 'Build complete'
}))
;
});
gulp.task('clean', function() {
$.log('Cleaning: ' + config.paths.destination);
$.del([].concat(config.paths.destination));
});
gulp.task('serve', function() {
var sourcePath = $.path.join(__dirname, config.paths.destination);
var port = 12857;
var serveFromPath = '/' + config.paths.buildPrefix;
log('Hosting ' + sourcePath + ' at http://localhost:' + port + serveFromPath);
$.connect()
.use(serveFromPath, $.serveStatic(sourcePath))
.listen(port);
});