-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
148 lines (130 loc) · 3.98 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
'use strict';
/**
* Import plugins
*/
var gulp = require('gulp'),
$ = require('gulp-load-plugins')(),
browserSync = require('browser-sync'),
reload = browserSync.reload,
runSequence = require('run-sequence'),
del = require('del');
/**
* Build vendors dependencies
*/
gulp.task('vendors', function() {
/**
* CSS VENDORS
*/
gulp.src([
''
])
.pipe($.concat('vendors.css'))
.pipe($.minifyCss())
.pipe(gulp.dest('build/css'));
/**
* JS VENDORS
* (with jQuery and Bootstrap dependencies first)
*/
gulp.src([
'bower_components/jquery/dist/jquery.js',
'bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/affix.js',
'bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/alert.js',
'bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/button.js',
'bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/carousel.js',
'bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/collapse.js',
'bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/dropdown.js',
'bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/modal.js',
'bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/tooltip.js',
'bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/popover.js',
'bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/scrollspy.js',
'bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/tab.js',
'bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap/transition.js'
])
.pipe($.concat('vendors.min.js'))
.pipe($.uglify())
.pipe(gulp.dest('build/js'));
/**
* FONTS SOURCES
* Important to add the bootstrap fonts to avoid issues with the fonts include path
*/
gulp.src([
'bower_components/bootstrap-sass-official/vendor/assets/fonts/bootstrap/*',
'assets/fonts/*'
])
.pipe(gulp.dest('build/fonts'));
});
/**
* Build styles from SCSS files
* With error reporting on compiling (so that there's no crash)
*/
gulp.task('styles', function() {
return gulp.src('assets/sass/antistatique.scss')
.pipe($.sass())
.on('error', $.util.beep)
.on('error', $.notify.onError(function (error) {
return 'Message to the notifier: ' + error.message;
}))
.pipe($.autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1'))
.pipe($.minifyCss())
.pipe(gulp.dest('build/css'));
});
/**
* Build JS
* With error reporting on compiling (so that there's no crash)
*/
gulp.task('scripts', function() {
return gulp.src('assets/js/*.js')
.pipe($.concat('main.js'))
.pipe(gulp.dest('build/js'))
.pipe($.rename({ suffix: '.min' }))
.pipe($.uglify())
.pipe(gulp.dest('build/js'));
});
/**
* Lint JS
*/
gulp.task('jshint', function () {
return gulp.src('assets/js/*js')
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish'))
.pipe($.if(!browserSync.active, $.jshint.reporter('fail')));
});
/**
* Build Hologram Styleguide
*/
gulp.task('styleguide', function () {
return gulp.src('hologram_config.yml')
.pipe($.hologram());
});
/**
* Clean output directories
*/
gulp.task('clean', del.bind(null, ['build', 'styleguide']));
/**
* Serve
*/
gulp.task('serve', ['styles'], function () {
browserSync({
server: {
baseDir: ['styleguide'],
},
open: false
});
gulp.watch(['**/*.html'], reload);
gulp.watch(['assets/sass/**/*.scss'], function() {
runSequence('styles', 'styleguide', reload);
});
});
/**
* Deploy to GH pages
*/
gulp.task('deploy', function () {
gulp.src("styleguide/**/*")
.pipe($.ghPages());
});
/**
* Default task
*/
gulp.task('default', ['clean'], function(cb) {
runSequence('vendors', 'styles', 'jshint', 'scripts', 'styleguide', cb);
});