This repository has been archived by the owner on Oct 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
114 lines (96 loc) · 2.84 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
'use strict';
/////// COMMON ///////
// Load plugins
var gulp = require('gulp');
var del = require('del');
var runSequence = require('run-sequence');
var $ = require('gulp-load-plugins')();
// Helper: SASS
function sassHelper(name, source, dest) {
return gulp.src(source)
.pipe($.rubySass({
style: 'compressed',
precision: 10
}))
.pipe($.autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(gulp.dest(dest))
.pipe($.size({ title: name }));
}
// Helper: Script
function scriptHelper(name, dest) {
return gulp.src([
'./bower_components/jquery/dist/jquery.js',
'./bower_components/jquery-sticky/jquery.sticky.js',
'./bower_components/devbridge-autocomplete/dist/jquery.autocomplete.js',
'./assets/scripts/main.js'
])
.pipe($.concat('docs.js'))
.pipe($.uglify())
.pipe(gulp.dest(dest))
.pipe($.size({ title: name }));
}
// Styles
gulp.task('styles', function() {
return sassHelper('styles', 'assets/styles/*.sass', 'dev/build/css');
});
// Custom
gulp.task('custom', function() {
return sassHelper('custom', 'example/styles/*.scss', 'dev/custom/css');
});
// JS
gulp.task('scripts', function() {
return scriptHelper('scripts', 'dev/build/js');
});
// Clean
gulp.task('clean', function(cb) {
del(['dev', 'build', '*.html'], cb);
});
/////// DEVELOPMENT ///////
// Prepare for development
gulp.task('prepare', function (cb) {
runSequence('clean', 'styles', 'scripts', 'custom', 'hologram', cb);
});
// Start Web Server
gulp.task('serve', function() {
gulp.src('dev')
.pipe($.webserver({
livereload: true,
open: true
}));
});
// Style Guide / UI Patterns
gulp.task('hologram', function() {
return gulp.src('hologram.yml')
.pipe($.hologram({ bundler: true }));
});
// Watch
gulp.task('watch', ['prepare'], function() {
gulp.start('serve');
gulp.watch('hologram.yml', ['hologram']);
gulp.watch('assets/templates/*.html', ['hologram']);
gulp.watch('assets/scripts/*.js', ['scripts', 'hologram']);
gulp.watch('assets/styles/*.sass', ['styles', 'hologram']);
gulp.watch('example/styles/*.scss', ['custom', 'hologram']);
});
/////// BUILD ///////
// Templates
gulp.task('templates', function() {
return gulp.src('assets/templates/*.html')
.pipe(gulp.dest('.'))
.pipe($.size({ title: 'templates' }));
});
// Build styles
gulp.task('build:css', function() {
return sassHelper('styles', 'assets/styles/*.sass', 'build/css');
});
// Build scripts
gulp.task('build:js', function() {
return scriptHelper('scripts', 'build/js');
});
// Build
gulp.task('default', function(cb) {
runSequence('clean', ['build:css', 'build:js', 'templates'], cb);
});